Inside the catch, the catch-scope is first for reading and writing.
In "practice" (as in: what implementations permit; not: what is used),
there is also this variation:
try { throw "oops" }
catch (f) {
function f() { console.log(f) }
console.log(f)
}
console.log(f)
This isn't permitted in ES5, and 'f' would be block-scoped if permitted
in ES6. In common non-standard extensions to ES5, the function and
references to 'f' in its body are bound outside the catch. I don't even
want to look at what happens with a function declaration in a catch
where the body references the catch parameter..
I'm currently looking at these edge cases for implementing
renaming (program transformation) - no fun.
§10.5 tells us that `var` creates bindings in the anonymous function's
environment, so the function's env has `e`, `o`, and `u` bindings.
§12.14 tells us that within the `catch`, a new environment is created
with the function's environment being the parent. So the assignment
to `e` is to the `catch`'s `e`, not the function's.
Which means that the single occurrence of 'e' in 'var e = "ho"' is bound
to two different scopes: outside the catch for creating a binding, in the
catch for assignment. As Allen anticipated, I was wondering about the
effects on mixing 'let' and 'var', too.
Claus
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss