archives

« Bugzilla Issues Index

#1116 — let syntax and extended grammar restriction


Per Nov 29 Resolution:


> In non-strict code: let, with single token lookahead (where the single token is either an Identifier, "[", or "{" ), at the start of a statement is a let declaration. (Accepted breaking change)


Extended grammar restriction:


(x) = 3; // allowed
({ y }) = 3; // allowed

var (x) = 3; // disallowed
var ({y}) = 3; // disallowed


in rev20 editor's draft


fixed in rev20 draft, Oct. 28, 2013


In the draft, only part of the `let` syntax restriction is covered:

ExpressionStatement[yield] :
[lookahead ∉ {{, function, class, let [ }] Expression[in, ?yield] ;


The missing part is "let {"


I don't believe there are any situations where
let {

is a valid head of an expression, so there is no reason to do a lookahead restriction for that.

But then again, I may be sleep walking and missing something.

Do you have something in mind?


No, not specifically and you're right it's not possible. I was just following up based on the consensus. I wonder why we explicitly included that?


(In reply to comment #5)
> No, not specifically and you're right it's not possible. I was just following
> up based on the consensus. I wonder why we explicitly included that?

I don't know. The notes didn't make a lot of sense by theselves, but I remembered that

var let = new Array;
let[n] = ... //is this a let declaration or an assignment

was the ambiguity that we decided to fix by saying that let [ is always a let declaration. So is let { but it doesn't have any ambiguities with an expression statement.

I'm going to close this again, because I don't think there is anything to fix. If anymore discovers new issues they can open a new bug.


(In reply to comment #6)

> I'm going to close this again, because I don't think there is anything to fix.
> If anymore discovers new issues they can open a new bug.

Yes, sorry—I should've reclosed.