On Fri, Jul 12, 2013 at 8:09 PM, Andrew Fedoniouk <[email protected] > wrote:
> On Fri, Jul 12, 2013 at 4:17 PM, Tab Atkins Jr. <[email protected]> > wrote: > > 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*. > > Your hypothesis would be true if not this case: > Tab's response is not a hypothesis, it's a generalization of the specification. ASI rules are defined, unambiguously, in the ECMAScript spec. > > return > { a:1 }; > > Why it injects ';' after the return? This > > return { a:1 }; > > is perfectly valid construction. > For the same reason I've mentioned several times in this thread: a [no LineTerminator here], which exists between return and the optional Expression: return [no LineTerminator here] Expression (optional); Rick > > > > >> BTW: what about "use strict" ? Does it govern ASI parsing rules? > >> If not then why? > > > > No, strict mode has no effect on ASI. > > > > Too bad IMO. > > > > -- > Andrew Fedoniouk. > > http://terrainformatica.com >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

