Skip to content

fix(parser): report syntax error for new super()#20384

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/new-super-syntax-error
Mar 15, 2026
Merged

fix(parser): report syntax error for new super()#20384
graphite-app[bot] merged 1 commit intomainfrom
fix/new-super-syntax-error

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Mar 14, 2026

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

Copilot AI review requested due to automatic review settings March 14, 2026 15:56
@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Mar 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new expression’s callee is a bare super.
  • Introduce a dedicated diagnostic for the new super() case.
  • Add a new misc/fail coverage case for new 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 14, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing fix/new-super-syntax-error (686bdca) with main (e62524d)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen force-pushed the fix/new-super-syntax-error branch from 822ebc7 to 686bdca Compare March 15, 2026 01:50
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 15, 2026
Copy link
Member Author

Boshen commented Mar 15, 2026

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)
@graphite-app graphite-app bot force-pushed the fix/new-super-syntax-error branch from 686bdca to ed5a7fb Compare March 15, 2026 02:12
@graphite-app graphite-app bot merged commit ed5a7fb into main Mar 15, 2026
22 checks passed
@graphite-app graphite-app bot deleted the fix/new-super-syntax-error branch March 15, 2026 02:24
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 15, 2026
camc314 pushed a commit that referenced this pull request Mar 16, 2026
### 🐛 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new super() should be rejected

2 participants