fix(parser): report syntax error for new super()#20384
fix(parser): report syntax error for new super()#20384graphite-app[bot] merged 1 commit intomainfrom
new super()#20384Conversation
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
|
822ebc7 to
686bdca
Compare
Merge activity
|
## Summary - Report a syntax error for `new super()` per the ECMAScript spec grammar - `MemberExpression` includes `SuperProperty` (`super.x`, `super[x]`) but NOT bare `super`, so `new super()` is invalid - `new super.method()` and `new super[x]()` remain valid Closes #20306 🤖 Generated with [Claude Code](https://claude.com/claude-code)
686bdca to
ed5a7fb
Compare
### 🐛 Bug Fixes - edb8677 ecmascript: Treat collection constructor with variable arg as side-effectful (#20383) (Dunqing) - 1f65c3f transformer: Emit design:paramtypes when class has static anonymous class expression (#20382) (bab) - fa70d5c transformer: Use implementation signature for design:paramtypes when constructor is overloaded (#20394) (bab) - ed5a7fb parser: Report syntax error for `new super()` (#20384) (Boshen) - e62524d minifier: Treat object spread of getters as having side effects (#20380) (Boshen) - f8fbd6e linter/plugins: Remove `hashbang` property from AST (#20365) (overlookmotel) ### ⚡ Performance - 30a2b0f minifier: Use atom_from_strs_array for template literal concat (#20386) (Boshen) - 690ce17 minifier: Use Vec::with_capacity for inline template expressions (#20389) (Boshen) - 9cd612f linter/plugins: Recycle comment objects (#20362) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
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