On Fri, Jul 12, 2013 at 3:55 PM, Andrew Fedoniouk
<[email protected]> wrote:
> Seems like I am not getting that famous ASI thing.
>
> I do not understand why here:
>
>   foo
>   (exp);
>
> there is no semicolon injected. It rather should be this:
>
>   foo;
>   (exp);
>
> if that ASI thing has any traces of logic behind.

It has a very simple logic, just not the one you're assuming.

You're probably thinking that the rule is "if a line doesn't end in a
semicolon, and you can insert one without causing this line or the
next to have a parse error, do so".  The actual rule is "if a line
doesn't end in a semicolon, attempt to join it with the following
line. If that causes a syntax error, insert a semicolon and try
again".

In other words, ASI only happens when a semicolon is *required*, not
when one is *possible*.

> BTW: what about "use strict" ? Does it govern ASI parsing rules?
> If not then why?

No, strict mode has no effect on ASI.

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to