I'd like to clarify something I've been reading from the specs, and verify if there is any action necessary.
for productions like for ( var f in [] ) { ... } and for (var f; ; ) { ... } we have the f binding name added to VarDeclaredNames of the for Statement. This happens from Static Semantics.
If it's a BlockStatement, we might encounter the Early SyntaxError when a lexical declared name also occurs in the VarDeclaredNames of the respective StatementList. Basically: { let f; var f; }.
Considering in the examples above for for, where bindings are appended to VarDeclaredNames, should this error also be observed?
Currently no engine observes the SyntaxError for cases like: for (var f in []) { let f; } and for (var f; ; ) { let f }.
So the possible solutions are:
- Am I missing any text in the spec saying this SyntaxError won't happen to names appended to VarDeclaredNames?
- We enforce the SyntaxError to be consistent and throw a SyntaxError also for names added to VarDeclaredNames and then redeclared as lexical names in the respective statement list? We add tests and expect all engines to fix this?
- We might add a text saying the Early Error doesn't observe names appended to the respective VarDeclaredNames from extensive productions. All browsers already comply to this behavior.
Thanks
I'd like to clarify something I've been reading from the specs, and verify if there is any action necessary.
for productions like
for ( var f in [] ) { ... }andfor (var f; ; ) { ... }we have the f binding name added to VarDeclaredNames of the for Statement. This happens from Static Semantics.If it's a BlockStatement, we might encounter the Early SyntaxError when a lexical declared name also occurs in the VarDeclaredNames of the respective StatementList. Basically:
{ let f; var f; }.Considering in the examples above for
for, where bindings are appended to VarDeclaredNames, should this error also be observed?Currently no engine observes the SyntaxError for cases like:
for (var f in []) { let f; }andfor (var f; ; ) { let f }.So the possible solutions are:
Thanks