Skip to content

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Nov 26, 2025

Currently we just emit "unexpected token", but we actually have a good amount of context here to provide better help + error message.

@github-actions github-actions bot added the A-parser Area - Parser label Nov 26, 2025
Copy link
Member Author

camchenry commented Nov 26, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Nov 26, 2025
@camchenry camchenry marked this pull request as ready for review November 26, 2025 02:14
Copilot AI review requested due to automatic review settings November 26, 2025 02:14
Copilot finished reviewing on behalf of camchenry November 26, 2025 02:17
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 26, 2025

CodSpeed Performance Report

Merging #16131 will not alter performance

Comparing 11-25-feat_parser_improve_diagnostic_for_unexpected_optional_declarations (dfa63e3) with main (891e0b4)

Summary

✅ 42 untouched
⏩ 3 skipped1

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.

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 enhances parser diagnostics by replacing a generic "Unexpected token" error with a more specific and helpful message when encountering optional declarations (?) in variable declarations where they are not allowed. The improvement provides clear guidance to developers by explaining the issue and suggesting a fix.

  • Adds a new diagnostic function unexpected_optional_declaration with contextual error messaging
  • Updates the variable declaration parser to use the improved diagnostic
  • Adds helpful suggestion to remove the ? token

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
crates/oxc_parser/src/diagnostics.rs Adds unexpected_optional_declaration function following established diagnostic patterns with clear error message and help text
crates/oxc_parser/src/js/declaration.rs Updates variable declarator parsing to use the new specific diagnostic instead of generic unexpected_token
tasks/coverage/snapshots/parser_misc.snap Updates test snapshots showing improved error messages for all affected test cases (oxc-2253.ts and oxc-5955-1.ts)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Nov 26, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 26, 2025

Merge activity

…#16131)

Currently we just emit "unexpected token", but we actually have a good amount of context here to provide better help + error message.
@graphite-app graphite-app bot force-pushed the 11-25-feat_parser_improve_diagnostic_for_unexpected_optional_declarations branch from dfa63e3 to db839ae Compare November 26, 2025 04:33
@graphite-app graphite-app bot merged commit db839ae into main Nov 26, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 11-25-feat_parser_improve_diagnostic_for_unexpected_optional_declarations branch November 26, 2025 04:38
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants