Commit 622cb5e
committed
Legal comments like `/* @foo @preserve */` were not being preserved when legal comment output was enabled. The parser only checked if the first `@` annotation matched known patterns, missing `@preserve`/`@license` later in the comment.
## Changes
**Parser (`oxc_parser/src/lexer/trivia_builder.rs`)**
- Add fallback check using `contains_license_or_preserve_comment` after `__PURE__`/`__NO_SIDE_EFFECTS__` checks
- Ensures `@license`/`@preserve` detected anywhere in comment text
## Example
```javascript
// Before: Legal comment not detected by parser
/* @foo @preserve */ function foo() {}
// Parser classifies as: CommentContent::None ❌
// After: Legal comment correctly detected
/* @foo @preserve */ function foo() {}
// Parser classifies as: CommentContent::Legal ✅
```
Related: rolldown/rolldown#7160
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> `/* @foo @preserve */` should be preserved when legal comment output is enabled even if comment output is disabled. rolldown/rolldown#7160 is related
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for you](https://github.com/oxc-project/oxc/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
1 parent 512e43a commit 622cb5e
1 file changed
+10
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| 255 | + | |
254 | 256 | | |
255 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
256 | 264 | | |
257 | 265 | | |
258 | 266 | | |
| |||
504 | 512 | | |
505 | 513 | | |
506 | 514 | | |
| 515 | + | |
| 516 | + | |
507 | 517 | | |
508 | 518 | | |
509 | 519 | | |
| |||
0 commit comments