Skip to content

fix(parser/trivia): correctly mark whether a block comment is on a newline#17754

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/01-07-asd
Jan 8, 2026
Merged

fix(parser/trivia): correctly mark whether a block comment is on a newline#17754
graphite-app[bot] merged 1 commit intomainfrom
c/01-07-asd

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Jan 7, 2026

@github-actions github-actions bot added A-parser Area - Parser A-codegen Area - Code Generation labels Jan 7, 2026
Copy link
Contributor Author

camc314 commented Jan 7, 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.

@camc314 camc314 changed the title asd fix(parser/trivia): correctly mark whether a block comment is on a newline Jan 7, 2026
@camc314 camc314 marked this pull request as ready for review January 7, 2026 16:36
Copilot AI review requested due to automatic review settings January 7, 2026 16:36
@github-actions github-actions bot added the C-bug Category - Bug label Jan 7, 2026
@camc314 camc314 changed the base branch from main to graphite-base/17754 January 7, 2026 16:38
@camc314 camc314 force-pushed the graphite-base/17754 branch from 3e0dff7 to 40899ee Compare January 7, 2026 16:38
@camc314 camc314 changed the base branch from graphite-base/17754 to c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators January 7, 2026 16:38
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 fixes a bug in the parser's trivia builder where block comments were incorrectly marked as being preceded by a newline. The fix introduces a separate tracking field saw_newline_for_comment to distinguish between newlines for trailing comment detection versus newlines for setting the preceded_by_newline metadata on comments.

Key changes:

  • Added saw_newline_for_comment field to track newlines since the last comment or token, separate from saw_newline which only tracks since the last token
  • Updated logic to correctly reset saw_newline_for_comment after block comments (but not line comments)
  • Added test case for consecutive block comments to verify the fix

Reviewed changes

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

Show a summary per file
File Description
crates/oxc_parser/src/lexer/trivia_builder.rs Adds saw_newline_for_comment field and updates logic to correctly track whether block comments are preceded by newlines
crates/oxc_codegen/tests/integration/comments.rs Adds new test case for consecutive block comments
crates/oxc_codegen/tests/integration/snapshots/misc_comments.snap Snapshot for the new test showing expected output
tasks/coverage/snapshots/transformer_babel.snap Improved test pass rate from 99.87% to 99.96% due to the fix
tasks/coverage/snapshots/minifier_babel.snap Improved test pass rate from 99.89% to 100.00% due to the fix
tasks/coverage/snapshots/codegen_babel.snap Improved test pass rate from 99.91% to 100.00% due to the fix

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

@camc314 camc314 force-pushed the c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators branch from 40899ee to def421c Compare January 7, 2026 16:41
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 7, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing c/01-07-asd (96adcca) with c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators (a6a5c3c)

Summary

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks1

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.

@camc314 camc314 force-pushed the c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators branch from def421c to 24aac35 Compare January 8, 2026 11:04
@camc314 camc314 force-pushed the c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators branch from 24aac35 to a6a5c3c Compare January 8, 2026 11:07
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jan 8, 2026
Copy link
Member

Boshen commented Jan 8, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators branch from a6a5c3c to c32e8d5 Compare January 8, 2026 12:34
Base automatically changed from c/01-07-fix_codegen_wrap_tsasexpression_in_parens_when_used_with_in_instanceof_operators to main January 8, 2026 12:40
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 8, 2026
@graphite-app graphite-app bot merged commit 7422b7e into main Jan 8, 2026
22 checks passed
@graphite-app graphite-app bot deleted the c/01-07-asd branch January 8, 2026 12:41
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-codegen Area - Code Generation A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants