Skip to content

feat(semantic): improve error message to add # for private identifiers#17779

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-08-feat_semantic_improve_error_message_to_add_for_private_identifiers
Jan 8, 2026
Merged

feat(semantic): improve error message to add # for private identifiers#17779
graphite-app[bot] merged 1 commit intomainfrom
01-08-feat_semantic_improve_error_message_to_add_for_private_identifiers

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Jan 8, 2026

class A {
    #a;
    #a
}

Chrome devtool throws:

VM411:3 Uncaught SyntaxError: Identifier '#a' has already been declared

@github-actions github-actions bot added A-semantic Area - Semantic C-enhancement Category - New feature or request labels Jan 8, 2026
Copy link
Member Author

Dunqing commented Jan 8, 2026


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.

@Dunqing Dunqing marked this pull request as ready for review January 8, 2026 03:22
@Dunqing Dunqing requested review from camc314 and Copilot January 8, 2026 03:22
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 pull request improves error messages for private class identifiers by adding the # prefix to match the format used by Chrome DevTools. The change affects two types of error messages: undeclared private fields and duplicate private identifier declarations.

  • Updated error messages to include # prefix for private identifiers
  • Modified duplicate class element checking to format private identifier names
  • Updated all test snapshots to reflect the new error message format

Reviewed changes

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

Show a summary per file
File Description
crates/oxc_semantic/src/diagnostics.rs Added # prefix to private field undeclared error message
crates/oxc_semantic/src/checker/javascript.rs Added logic to format private identifier names with # prefix for duplicate declaration errors
tasks/coverage/snapshots/parser_typescript.snap Updated test snapshots with new error message format
tasks/coverage/snapshots/parser_test262.snap Updated test snapshots with new error message format
tasks/coverage/snapshots/parser_misc.snap Updated test snapshots with new error message format
tasks/coverage/snapshots/parser_babel.snap Updated test snapshots with new error message format

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 8, 2026

Merging this PR will not alter performance

Summary

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing 01-08-feat_semantic_improve_error_message_to_add_for_private_identifiers (f31e6c1) with main (5755b2d)2

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.

  2. No successful run was found on main (de5966d) during the generation of this report, so 5755b2d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Dunqing Dunqing force-pushed the 01-08-feat_semantic_improve_error_message_to_add_for_private_identifiers branch from 077b170 to f31e6c1 Compare January 8, 2026 05:45
@camc314 camc314 self-assigned this Jan 8, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jan 8, 2026
Copy link
Contributor

camc314 commented Jan 8, 2026

Merge activity

…ers (#17779)

```js
class A {
    #a;
    #a
}
```

Chrome devtool throws:

`VM411:3 Uncaught SyntaxError: Identifier '#a' has already been declared`
@graphite-app graphite-app bot force-pushed the 01-08-feat_semantic_improve_error_message_to_add_for_private_identifiers branch from f31e6c1 to 2261e6e Compare January 8, 2026 09:06
@graphite-app graphite-app bot merged commit 2261e6e into main Jan 8, 2026
20 checks passed
@graphite-app graphite-app bot deleted the 01-08-feat_semantic_improve_error_message_to_add_for_private_identifiers branch January 8, 2026 09:12
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 8, 2026
Dunqing pushed a commit that referenced this pull request Jan 12, 2026
### 🚀 Features

- 10426af codegen: Print soft space between inline block comments on the
same line (#17799) (camc314)
- 2261e6e semantic: Improve error message to add `#` for private
identifiers (#17779) (Dunqing)

### 🐛 Bug Fixes

- 7422b7e parser/trivia: Correctly mark whether a block comment is on a
newline (#17754) (camc314)
- c32e8d5 codegen: Wrap `TSAsExpression` in parens when used with
in/instanceof operators (#17752) (camc314)
- 5755b2d semantic: Report duplicate private identifier for static and
instance elements (#17591) (camc314)
- 0600df3 isolated_declarations: Only print jsdoc comments (#17748)
(camc314)
- ef7e014 parser: Preserve `@__NO_SIDE_EFFECTS__` annotation with
parenthesized expressions (#17711) (camc314)
- 59a6228 parser: Detect TS1363 error for type-only imports with mixed
default and named/namespace bindings (#17712) (Copilot)

### ⚡ Performance

- 864f1fa semantic: Mark duplicate class element error reporting as cold
(#17746) (camc314)
- 3a452b8 semantic: Use smallvec for storing reference IDs (#17731)
(camchenry)
- d5979dc minifier: Do not allocate when checking to convert `const` to
`let` (#17730) (camchenry)
- 3f4429c parser: Do not re-allocate TS interface heritage (#17692)
(camchenry)

### 📚 Documentation

- 120a27c minifier: Add prettier-ignore for js-in-md part (#17687)
(leaysgur)

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-semantic Area - Semantic C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants