archives

« Bugzilla Issues Index

#4174 — B.3.5 VariableStatements in Catch blocks: Incorrect redefinition of steps


B.3.5 VariableStatements in Catch blocks

The current redefinition of step 6.d.ii.2 makes this code valid:
---
try { } catch(e) {
eval("for (var e of []) ;")
}

{ let e;
eval("for (var e of []) ;")
}
---

but disallows:
---
{ let e;
eval("for (var e in []) ;")
}
---

I think the correct definition is:
---
ii. If thisEnvRec is not an object Environment Record, then
1. NOTE: The environment of with statements can not contain any lexical declaration so it doesn’t need to be checked for var/let hoisting conflicts.
2. For each name in varNames, do
a. If thisEnvRec. HasBinding(name) is true, then
i. If thisEnvRec is not the Environment Record for a Catch clause, then throw a SyntaxError exception.
ii. Else, if name is not only bound by a VariableStatement or the VariableDeclarationList of a for statement, or the ForBinding of a for-in statement, then throw a SyntaxError exception.
b. NOTE: A direct eval will not hoist var declaration over a like-named lexical declaration.
---


fixed inrev37 editor's draft


In Rev37