Skip to content

fix(minifier): preserve var inside catch with same-named parameter#21366

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/minifier-catch-var-hoisting
Apr 15, 2026
Merged

fix(minifier): preserve var inside catch with same-named parameter#21366
graphite-app[bot] merged 1 commit intomainfrom
fix/minifier-catch-var-hoisting

Conversation

@Dunqing
Copy link
Copy Markdown
Member

@Dunqing Dunqing commented Apr 13, 2026

Summary

  • Block inlining of var declarators whose symbol has the CatchVariable flag, preventing loss of function-scoped hoisting
  • Check symbol_redeclarations before removing catch parameters, preventing semantic changes when the catch body contains a var redeclaration
  • Uses existing semantic data (CatchVariable flag and symbol_redeclarations) instead of manual AST walks

Closes #17307

Test plan

  • cargo test -p oxc_minifier — 476 tests pass
  • Verified minified output matches original JS semantics via node

🤖 Generated with Claude Code

@github-actions github-actions Bot added A-minifier Area - Minifier C-bug Category - Bug labels Apr 13, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 13, 2026

Merging this PR will not alter performance

✅ 44 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing fix/minifier-catch-var-hoisting (6c0448b) with main (9fb2d9c)

Open in CodSpeed

Footnotes

  1. 7 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.

Comment thread crates/oxc_minifier/tests/peephole/substitute_alternate_syntax.rs
@sapphi-red sapphi-red added the 0-merge Merge with Graphite Merge Queue label Apr 15, 2026
Copy link
Copy Markdown
Member

sapphi-red commented Apr 15, 2026

Merge activity

#21366)

## Summary

- Block inlining of `var` declarators whose symbol has the `CatchVariable` flag, preventing loss of function-scoped hoisting
- Check `symbol_redeclarations` before removing catch parameters, preventing semantic changes when the catch body contains a `var` redeclaration
- Uses existing semantic data (`CatchVariable` flag and `symbol_redeclarations`) instead of manual AST walks

Closes #17307

## Test plan

- [x] `cargo test -p oxc_minifier` — 476 tests pass
- [x] Verified minified output matches original JS semantics via `node`

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app Bot force-pushed the fix/minifier-catch-var-hoisting branch from 6c0448b to b0e8f13 Compare April 15, 2026 02:57
@graphite-app graphite-app Bot merged commit b0e8f13 into main Apr 15, 2026
26 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Apr 15, 2026
@graphite-app graphite-app Bot deleted the fix/minifier-catch-var-hoisting branch April 15, 2026 03:01
Dunqing added a commit that referenced this pull request Apr 16, 2026
### 💥 BREAKING CHANGES

- 24fb7eb allocator: [**BREAKING**] Rename `Box` and `Vec` methods
(#21395) (overlookmotel)

### 🚀 Features

- ce5072d parser: Support `turbopack` magic comments (#20803) (Kane
Wang)
- f5deb55 napi/transform: Expose `optimizeConstEnums` and
`optimizeEnums` options (#21388) (Dunqing)
- 24b03de data_structures: Introduce `NonNullConst` and `NonNullMut`
pointer types (#21425) (overlookmotel)

### 🐛 Bug Fixes

- d7a359a ecmascript: Treat update expressions as unconditionally
side-effectful (#21456) (Dunqing)
- 56af2f4 transformer/async-to-generator: Correct scope of inferred
named FE in async-to-generator (#21458) (Dunqing)
- b3ed467 minifier: Avoid illegal `var;` when folding unused arguments
copy loop (#21421) (fazba)
- b0e8f13 minifier: Preserve `var` inside `catch` with same-named
parameter (#21366) (Dunqing)
- 4fb73a7 transformer/typescript: Preserve execution order for accessor
with `useDefineForClassFields: false` (#21369) (Dunqing)

### ⚡ Performance

- da3cc16 parser: Refactor out `LexerContext` (#21275) (Ulrich Stark)

### 📚 Documentation

- c5b19bb allocator: Reformat comments in `Arena` (#21448)
(overlookmotel)
- 091e88e lexer: Update doc comment about perf benefit of reading
through references (#21423) (overlookmotel)
- 922cbee allocator: Remove references to "bump" from comments (#21397)
(overlookmotel)

Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minifier: redeclaration of catch binding causes incorrect minification

3 participants