Give "as" variables in with statements separate scopes (#12254)
Use renaming to allow two with statements to define the same variable
using incompatible types. The implementation is pretty simple-minded
and doesn't work in cases where there is even a hint of potential
ambiguity about which variant of a variable a reference targets, typically
due to functions.
This could be generalized to for statements in the future.
Fixes #12246.