archives

« Bugzilla Issues Index

#2665 — 12.3: Optional Arguments in "MemberExpression : new super Arguments" leads to Shift/Reduce conflicts


This is the same issue as in bug 2338. Draft rev23 added a lookahead restriction, but the issue still persists.

For the input token sequence "new super ( )" it cannot be decided if it has to parsed as:
- LeftHandSideExpression[CallExpression[ MemberExpression["new super"] "( )"]]
- or as LeftHandSideExpression[MemberExpression["new super ( )"]]

Shouldn't it be possible to resolve this issue by moving "new super" without optional arguments to NewExpression? That way no lookahead restriction is required and it's still possible to use "new super" as a standalone expression.

---
MemberExpression:
PrimaryExpression
MemberExpression [ Expression ]
MemberExpression . IdentifierName
MemberExpression TemplateLiteral
super [ Expression ]
super . IdentifierName
new super Arguments
new MemberExpression Arguments

NewExpression:
MemberExpression
new NewExpression
new super
---


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

%error-verbose

%token SUPER "super"
%token NEW "new"

%%

leftHandSideExpression : newExpression
| callExpression
;

arguments : '(' ')' ;

callExpression : memberExpression arguments ;

newExpression : memberExpression ;

memberExpression : NEW SUPER arguments
| NEW SUPER
;

%%
---


this looks pretty good and preserves the grammar structure from before the addition of super


fixed in rev24 editor's draft


fixed in rev24