Skip to content

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Nov 4, 2025

Improves error message for imbalanced tokens.

 × Expected `,` or `]` but found `const`
   ╭─[misc/fail/imbalanced-array-expr.js:2:1]
 1 │ const foo = [0, 1
   ·             ┬
   ·             ╰── Opened here
 2 │ const bar = 2
   · ──┬──
   ·   ╰── `,` or `]` expected
   ╰────

The error message for this case was:

  x Expected `,` but found `const`
   ,-[:2:1]
 1 | const foo = [0,1
 2 | const bar = 2
   : ^^|^^
   :   `-- `,` expected
   `----

This change makes it clear why the parser is expecting , and also tell that it can be fixed by adding the closing token somewhere.

Copy link
Member Author

sapphi-red commented Nov 4, 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 A-parser Area - Parser label Nov 4, 2025
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Nov 4, 2025
@sapphi-red sapphi-red requested a review from Boshen November 4, 2025 12:16
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 4, 2025

CodSpeed Performance Report

Merging #15269 will not alter performance

Comparing 11-03-feat_parser_improve_error_message_for_missing_closing_tokens (d067399) with 11-03-feat_parser_improve_error_message_for_missing_conditional_alternative (d28a78e)

Summary

✅ 37 untouched

@sapphi-red sapphi-red force-pushed the 11-03-feat_parser_improve_error_message_for_missing_conditional_alternative branch from 95550fb to d28a78e Compare November 4, 2025 12:18
@sapphi-red sapphi-red force-pushed the 11-03-feat_parser_improve_error_message_for_missing_closing_tokens branch from e580442 to d067399 Compare November 4, 2025 12:18
@sapphi-red sapphi-red marked this pull request as ready for review November 4, 2025 12:25
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 4, 2025
Copy link
Member

Boshen commented Nov 4, 2025

Merge activity

Improves error message for imbalanced tokens.
```
 × Expected `,` or `]` but found `const`
   ╭─[misc/fail/imbalanced-array-expr.js:2:1]
 1 │ const foo = [0, 1
   ·             ┬
   ·             ╰── Opened here
 2 │ const bar = 2
   · ──┬──
   ·   ╰── `,` or `]` expected
   ╰────
```

The error message for this case was:
```
  x Expected `,` but found `const`
   ,-[:2:1]
 1 | const foo = [0,1
 2 | const bar = 2
   : ^^|^^
   :   `-- `,` expected
   `----
```

This change makes it clear why the parser is expecting `,` and also tell that it can be fixed by adding the closing token somewhere.
@graphite-app graphite-app bot force-pushed the 11-03-feat_parser_improve_error_message_for_missing_conditional_alternative branch from d28a78e to 2ef8f01 Compare November 4, 2025 13:13
@graphite-app graphite-app bot force-pushed the 11-03-feat_parser_improve_error_message_for_missing_closing_tokens branch from d067399 to d4f6545 Compare November 4, 2025 13:14
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 4, 2025
Base automatically changed from 11-03-feat_parser_improve_error_message_for_missing_conditional_alternative to main November 4, 2025 13:18
@graphite-app graphite-app bot merged commit d4f6545 into main Nov 4, 2025
22 checks passed
@graphite-app graphite-app bot deleted the 11-03-feat_parser_improve_error_message_for_missing_closing_tokens branch November 4, 2025 13:19
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.

3 participants