archives

« Bugzilla Issues Index

#2768 — 13.6 Iteration Statements: lookahead restriction for "for-of" needs to be "let", not "let ["


13.6 Iteration Statements

Change lookahead restriction for the for-of statement back to "let" to resolve a shift/reduce resp. reduce/reduce conflict.

Simplified grammar to show shift/reduce conflict:
---
%start statement

%error-verbose

%token ID
%token FOR "for"
%token OF "of"
%token LET "let"

%%

statement : forOfStatement | ';' ;

forOfStatement : FOR '(' leftHandSideExpression OF assignmentExpression ')' statement
| FOR '(' forDeclaration OF assignmentExpression ')' statement
;

forDeclaration : LET bindingIdentifier ;
bindingIdentifier : ID | OF | LET ;

assignmentExpression : leftHandSideExpression ;

leftHandSideExpression : identifierReference ;
identifierReference : ID | OF | LET ;

%%
---


fixed in rev33 editor's draft

Also removed look-ahead restriction on for-in which tests suggest is unnecessary.

for;; still need the let [ look-ahead restriction, just like ExpressionStatement


(In reply to Allen Wirfs-Brock from comment #1)
> fixed in rev33 editor's draft
>
> Also removed look-ahead restriction on for-in which tests suggest is
> unnecessary.
>
> for;; still need the let [ look-ahead restriction, just like
> ExpressionStatement

Wasn't the lookahead issue in for-of already resolved in rev25?

And for-in needs restriction on `let [` to ensure `for (let in letters);` still works, right?


fixed in rev33