Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: ! function Date: Fri, 08 May 2015 00:26:16 +0200 Organization: solani.org Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1431037568 17398 eJwNyUkBwDAIBEBLXAtBDoHiX0I634E6e4c53LDYlRC6EUy3ypNJkSfDWug0IPNvz8z1r5haHwXPELo= (7 May 2015 22:26:08 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 7 May 2015 22:26:08 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 X-User-ID: eJwNycEBwCAIA8CVREjQcQSb/Uew9z04jZ1BMCCokrvc+7RCOv+tDyPbBqcuuDCjvI7d1CjtByqjEY8= In-Reply-To: Cancel-Lock: sha1:htkJ6NhhZ624jmrt4ZujQTDYsDo= X-NNTP-Posting-Host: eJwFwQERADEIAzBLT4H2J4fB4V/CknQaW8Fk5Ob2/tGihVml2gkBo6i+Z6YG8IMv4bxULR4QihCW Xref: csiph.com comp.lang.javascript:27562 I wrote: > Evertjan. wrote: > > >> But why does this work: >> >> -function(a){alert(a);return 2}('hi') >> >> and this does not: >> >> function(a){alert(a);return -2}('hi') >> >> ?? > > while the second line is parsed as (again simplified) > > SourceElement -> FunctionDeclaration -> ... > > and the remaining ('hi') is a syntax error, as no ASI applies here. That's wrong. According to ES 5.1 the line can't be parsed as FunctionDeclaration, because the Identifier is missing. Actually, the code doesn't match any production, and as such is syntactically invalid. -- Christoph M. Becker