Annex A of 5th Edition

Joseph Spencer js.developer.undefined at gmail.com
Thu Sep 6 22:10:23 PDT 2012


Wow, thanks for the reference to clause 16 (c16).  I'm having a blast
getting further into the spec and it really helps to have these
conversations about it!

I believe its safe to say then that operating on c16 alone, FF handles
the spec appropriately and Chrome probably gave too much heed to this:

"An early error is an error that can be detected and reported prior to
the evaluation of any construct in the <i>Program</i> containing the
error" - c16

This must account for why the following doesn't throw an early error in
Chrome:

function passes(){alert(++++someVar);}

In either case, it appears that Annex A is slightly out of sync with
c16, and may benefit from being updated.


On Thu, 2012-09-06 at 16:35 -0700, Brendan Eich wrote:
> Allen Wirfs-Brock wrote:
> > On Sep 6, 2012, at 12:17 PM, Joseph Spencer wrote:
> >
> >> My apologies on that one.  I meant to type the following:
> >>
> >> PostfixExpression:
> >>      LeftHandSideExpression [no LineTerminator here] ++
> >>      LeftHandSideExpression [no LineTerminator here] --
> >>
> >> PrefixExpression:
> >>      ++ [no LineTerminator here] LeftHandSideExpression
> >>      -- [no LineTerminator here] LeftHandSideExpression
> >>
> >> It appears to me that as currently written the following is considered valid sytax:
> >>
> >> ++++someVar;
> >>
> >> I hadn't thought about es3 compatability though, so I could see the reasoning in keeping it as is.
> >> As a noobie (and most likely someone in dire need of correction ;) approaching this , it seems to
> >> me that there are a few loose ends in the grammar.  For instance, the following statements seem
> >> allowable by the grammar as currently written:
> >>
> >>
> >> ++typeof someVar;
> >> ++new Date();
> >> ++null;
> >>
> >> My knowledge is lacking on this though, so I am probably missing something.  I was surprised
> >> to find that the following is valid syntax and a perfectly legal FunctionDeclaration, but throws a
> >> ReferenceError when executed:
> >>
> >> function failPlease(){
> >>     alert(++++a);
> >> }
> >
> > According to the specification, those all should produce runtime ReferenceError exceptions.  However, at least Firefox, reports them as early syntax errors.  Technically, that is out of conformance with the spec.
> 
> Really? Clause 16 says:
> 
> "An implementation must treat any instance of the following kinds of 
> errors as an early error:
> 
> * ...
> * Attempts to call PutValue on any value for which an early 
> determination can be made that the value is
> not a Reference (for example, executing the assignment statement 3=4)."
> 
> How are we not conforming?
> 
> > Based upon that evidence, it would appear that FF implements a grammar that is closer to you are suggesting rather than what is in the spec.
> 
> No. We implement a recursive descent parser that follows the grammar but 
> does early error checking based on parse tree inspection.
> 
> /be




More information about the es-discuss mailing list