Skip to content

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

Open
Boshen wants to merge 1 commit intomainfrom
fix/new-super-syntax-error
Open

fix(parser): report syntax error for new super()#20384
Boshen wants to merge 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.

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>
@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

  • Mar 15, 1:53 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 15, 2:01 AM UTC: Boshen added this pull request to the Graphite merge queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue 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