Commit f6b56d6
committed
fix(ecmascript): resolve identifier value type via tracked constants
`value_type` returned `Undetermined` for any non-global identifier, even
when the binding had zero writes and a known constant initializer. As a
result `slot?.()` on a `let slot;` (with all writers tree-shaken away)
was not folded to `void 0`, leaving dead optional calls in the output.
Consult `get_constant_value_for_reference_id` for non-global identifier
references and map the resulting `ConstantValue` to a `ValueType`. This
lets `fold_chain_expr` (and other consumers of `value_type`) recognise
read-only `let`/`const` bindings whose value is statically known.
Closes rolldown/rolldown#92811 parent 24946be commit f6b56d6
2 files changed
Lines changed: 32 additions & 0 deletions
File tree
- crates
- oxc_ecmascript/src/constant_evaluation
- oxc_minifier/tests/peephole
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
55 | 67 | | |
56 | 68 | | |
57 | 69 | | |
| |||
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
94 | 112 | | |
95 | 113 | | |
96 | 114 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
0 commit comments