Annex A of 5th Edition

Brendan Eich brendan at
Thu Sep 6 16:35:09 PDT 2012

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.


More information about the es-discuss mailing list