Eric Suen wrote:
> a = a
>  /a/
> 
> this will cause syntax error instead of
> 
> a = a;
> /a/

Yes, it will. Are you saying that this is a counterexample? AFAICS it is
not: in this example there is no context where both a DivisionPunctuator
and a RegularExpressionLiteral are permitted as the next token.

Note that the first '/' is in a context where a division is permitted (and
a RegularExpressionLiteral is not). Therefore there is no possibility of a
semicolon being inserted there, since there is no syntax error at that
point. (In fact this is precisely the kind of example that was covered by
the last part of note [*1] in my previous post.)

At the risk of belabouring this point, semicolon insertion never involves
backtracking (and thank foo for that; it's complicated enough without it).
If some prefix of the token stream, in this case

 a = a /

could be extended with any suffix to make a syntactically valid stream
(for example, 'a = a / 1 ;'), then no semicolon will be inserted before
the end of that prefix, even if there is a syntax error later in the
actual token stream. This is an implicit consequence of the wording
"as the program is parsed from left to right" in section 7.9.1.

-- 
David-Sarah Hopwood
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to