The trouble with ambiguous grammars

Brendan Eich brendan at
Fri Oct 17 15:47:30 PDT 2008

On Oct 17, 2008, at 3:39 PM, Brendan Eich wrote:

> On Oct 17, 2008, at 12:25 PM, Waldemar Horwat wrote:
>> Here's a clearer case that Firefox gets wrong (or your grammar gets
>> wrong, depending on your point of view):
>> function f() {return "f"}
>> var x = 3;
>> let (a = 1) a ? f : x++();
>> The grammar states that the last statement must evaluate to "f".
>> Firefox gives a syntax error.  This is incorrect because the let
>> expression up to the ++ is a PrimaryExpression so can be used as the
>> left operand of a function call.

Er, you are right, I should have acknowedged this point. The rest of  
my post is about x++() not being a valid sentence, which supports your  

While we don't have any usability problems, and torturous statements  
such as

let (a = 1) a ? f : x++();

are not written by real users (they'd parenthesize to clear up  
things), I agree that we don't want the "prove a negative" problem.


More information about the Es-discuss mailing list