archives

« Bugzilla Issues Index

#2770 — 15.1.9 ScriptEvaluationTask: Don't require additional pass over parse tree to detect early errors


15.1.9 Runtime Semantics: ScriptEvaluationTask ( source ).

Implementations should be allowed to parse and analyze the source text at the same time. The current wording suggests that early error detection must not take place until after the complete source was parsed.


Note to self:
Impl. could simply defer error reporting for early errors until the source was completely parsed. This avoids to perform an additional pass over the parse tree.

Also:
Ignoring error messages for now, the order in which the source is parsed and early error detection takes place does not matter, because any error results in a SyntaxError. Well, it does not matter most of the time. The only exception are early ReferenceErrors for code like `0 = 1` or `++0`. Maybe it is possible to change the early ReferenceErrors to early SyntaxErrors?

There shouldn't be any web-compatibility issues:
- JavaScriptCore and IE11 do not perform any early error detection for either `++0` or `= 1`
- SpiderMonkey reports a SyntaxError instead of a ReferenceError for `++0`
- V8 is compliant for `0 = 1` and `++0`, but erroneously reports a ReferenceError instead of a SyntaxError for `for (0 in o);`


fixed in rev25 editor's draft

why does it matter whether "0 = 1" is an early Reference Error or an early Syntax Error? It either case they are reported as an early error and prevents evaluation of the entire script.


(In reply to comment #2)
> why does it matter whether "0 = 1" is an early Reference Error or an early
> Syntax Error?

Because it is an observable difference and therefore needs to be tested in test262:
https://github.com/tc39/test262/blob/master/test/suite/ch11/11.13/11.13.1/11.13.1-1-1.js#L19


fixed in rev25 editor's draft