archives

« Bugzilla Issues Index

#3933 — 13.6 Iteration Statements: Restore lookahead restriction "let [" in for-in statement to avoid shift/reduce conflict


13.6 Iteration Statements

The "let [" lookahead restriction in for-in statements was removed as part of bug 2768, even though 2768 was only about for-of statements.

Example grammar to show the shift/reduce conflict.
Change "leftHandSideExpression_noLetBracket" in "forInStatement" to "leftHandSideExpression" to see the shift/reduce conflict in bison.
---
%start statement

%error-verbose

%token ID
%token FOR "for"
%token IN "in"
%token LET "let"

%%

statement : forInStatement | ';' ;

forInStatement : FOR '(' leftHandSideExpression_noLetBracket IN expression ')' statement
| FOR '(' forDeclaration IN expression ')' statement
;

forDeclaration : LET forBinding ;
forBinding : bindingIdentifier | bindingPattern ;
bindingPattern : arrayBindingPattern ;
arrayBindingPattern : '[' bindingIdentifier ']' ;
bindingIdentifier : ID | LET ;

expression : assignmentExpression ;
assignmentExpression : leftHandSideExpression ;
leftHandSideExpression : memberExpression ;
memberExpression : identifierReference
| memberExpression '[' expression ']'
;

leftHandSideExpression_noLetBracket : memberExpression_noLetBracket ;
memberExpression_noLetBracket : LET
| memberExpression_noLetBracketList
;
memberExpression_noLetBracketList : identifierReference_noLet
| memberExpression_noLetBracketList '[' expression ']'
;

identifierReference : ID | LET ;
identifierReference_noLet : ID ;

%%
---


fixed in rev34 editor's draft

restored for-in and for;; lookahead restrictions.


fixed in rev34