-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Labels
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
class C extends class {} {
constructor() { new super() }
}Configuration file name
No response
Configuration
REPL
Current and expected behavior
Current: The parser parses successfully
Expect: The parser should reject new super()
Environment
REPL
Possible solution
check callee.type in parseNewCallee.
Additional context
Per spec:
NewExpression[Yield, Await] :
MemberExpression[?Yield, ?Await]
new NewExpression[?Yield, ?Await]
MemberExpression[Yield, Await] :
PrimaryExpression[?Yield, ?Await]
MemberExpression[?Yield, ?Await] [ Expression[+In, ?Yield, ?Await] ]
MemberExpression[?Yield, ?Await] . IdentifierName
MemberExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged]
SuperProperty[?Yield, ?Await]
MetaProperty
new MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
MemberExpression[?Yield, ?Await] . PrivateIdentifier
new super() is not covered by the NewExpression production since the MemberExpression production within new MemberExpression Arguments does not cover lone super.
V8/SM/JSC/TypeScript all reject this case.
Reactions are currently unavailable