fix(parser): report syntax error for new super()#20384
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the JS parser to reject new super() as a syntax error (per ECMAScript grammar), while keeping new super.prop() / new super[prop]() valid. It also adds coverage input to ensure the invalid form is exercised by the coverage suite.
Changes:
- Add a parser check that emits a diagnostic when a
newexpression’s callee is a baresuper. - Introduce a dedicated diagnostic for the
new super()case. - Add a new
misc/failcoverage case fornew super();.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tasks/coverage/misc/fail/new-super.js | Adds a failing coverage input for new super();. |
| crates/oxc_parser/src/js/expression.rs | Emits an error when parsing new expressions whose callee is Expression::Super. |
| crates/oxc_parser/src/diagnostics.rs | Adds a new diagnostic constructor for the new super() error. |
You can also share your feedback on Copilot code review. Take the survey.
Merging this PR will not alter performance
Comparing Footnotes
|
Per the ECMAScript spec, `MemberExpression` includes `SuperProperty` (`super.x`, `super[x]`) but NOT bare `super`, so `new super()` is invalid. `new super.method()` remains valid. Closes #20306 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
822ebc7 to
686bdca
Compare
Merge activity
|
Summary
new super()per the ECMAScript spec grammarMemberExpressionincludesSuperProperty(super.x,super[x]) but NOT baresuper, sonew super()is invalidnew super.method()andnew super[x]()remain validCloses #20306
🤖 Generated with Claude Code