Latest Results
fix(es/minifier): Preserve `this` and inferred names in sequence expressions (#12693)
<!-- Note: CI script will automatically rebase your PR so please do not
rebase unless required -->
**Description:**
Two optimizations change the meaning of a sequence expression when they
remove its `0` placeholder.
1. `Expr::directness_matters` did not include `super` property access.
The optimizer changed `(0, super.method)()` to `super.method()`. This
changes `this` from `undefined` to the current object. The same error
occurs for ``(0, super.method)`` `` and for `super` in object literals.
This PR adds `Expr::SuperProp` to `directness_matters`.
2. The Pure pass changed `(0, function () {})` to `function () {}`. When
the value is assigned in `var f = ...`, `{ k: ... }`, a class field, a
pattern default, or a logical assignment, the function then gets an
inferred name. This breaks `keep_fnames` and `keep_classnames`. Now the
Pure pass keeps the `0` in front of an anonymous function, arrow
function, or class when the matching option is on. The output does not
change when the options are off.
I found these errors while I reviewed #12684. That PR replaces calls to
empty functions in a sequence with `0`. After that PR, the same errors
also occur for inputs that work today.
Two new fixtures cover the changes: `seq-super-callee` and
`seq-keep-names`. Each fixture checks the output snapshot. It also
compares the stdout of the original code with the stdout of the code
after two minifications (`expected.repeat-stdout`).
Local validation:
- `cargo fmt --all`: done.
- `cargo test -p swc_ecma_minifier --no-fail-fast`: passed.
- `./scripts/exec.sh` in `crates/swc_ecma_minifier`: passed.
- `cargo test -p swc_ecma_ast -p swc_ecma_transforms_optimization
--no-fail-fast`: passed.
- `cargo clippy -p swc_ecma_ast -p swc_ecma_minifier -p
swc_ecma_transforms_optimization --all-targets -- -D warnings`: passed.
- `cargo clippy --all --all-targets -- -D warnings`: not completed. The
build of `openssl-sys` failed because `pkg-config` is not installed on
this machine.
- CI and review: pending.
**Related issue (if exists):**
None.
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Latest Branches
0%
LingyuCoder:seal/fix-noop-sequence-calls 0%
0%
kdy1/pr-12684-regression-inputs © 2026 CodSpeed Technology