es/minifier: property mangling leaves literal property references unchanged
Describe the bug
Property definitions are mangled, but visit_mut_member_expr rewrites only identifier properties and no visitor rewrites string-literal in operands. Exact literal references therefore continue using the old name after the definition has changed.
Input code
const obj={longprop:1}; console.log(obj["longprop"],"longprop" in obj)Config
Options used by the exact-source reproduction:
{
"compress": {
"defaults": false
},
"mangle": {
"props": {
"regex": "^longprop$"
}
},
"module": false
}Link to the code that reproduces this issue
Portable input and settings in SWC Playground
SWC Info output
Source build of swc_ecma_minifier 61.0.5, commit 246e6156ca14eaa07243ac8d9aa994c91c95cf3d, macOS arm64, Rust 1.96.0-nightly (f5eca4fcf 2026-04-09), Node v20.20.2.
The observed checkout and freshly fetched authoritative origin/main are the same commit. Fetch: git fetch --no-tags origin main, 2026-09-09T03:15:52Z, repository swc-project/swc. Reproduction was performed in a separate checkout of that fetched commit. Thus the cause remains on the default branch, not only in an older release.
For minify cases, the source harness follows the repository example: parse, resolve bindings, convert Terser compressor options, call optimize, apply fixer, emit, and execute original/output separately. Script-only behavior uses Script parsing. The playground carries portable source/settings; its published version is not evidence that the release matches the pinned source build. No implementation change was applied.
Expected behavior
Exit 0; stdout:
1 trueActual behavior
const obj={o:1};console.log(obj["longprop"],"longprop"in obj);Exit 0; stdout:
undefined falseVersion
swc_ecma_minifier 61.0.5, 246e6156ca14eaa07243ac8d9aa994c91c95cf3d (also freshly fetched main).
Additional context
Responsible code: pass/mangle_props.rs:179.
Shorthand destructuring was tested and already works because an earlier pass expands it; it is not part of this defect. #2171 (keep_quoted configuration) and #10332 (safe local-object inference) are different requests.
Proposed Scope
Apply the same selected property-name mapping to statically known string-literal property positions: computed member/super accesses, computed literal definitions, and in operands. Preserve arbitrary string values, dynamic keys, reserved properties, and regex filtering.
Limit the change to this semantic boundary and its regression coverage. No API expansion, dependency update, migration, deployment, or feature-flag rollout is required. Preserve the documented minifier assumptions; the reproduction does not require overriding builtin implementations.
Acceptance Criteria and Test Scenarios
- The primary input must print 1 true.
- Dot access remains correct.
- Reserving longprop keeps both the old definition and literal references and prints 1 true.
- Cover an isolated in check, computed literal definition, and unrelated string value "longprop" that must not be rewritten.
- Add regression coverage in the existing SWC-owned fixture/execution suites under
crates/swc_ecma_minifier/tests/fixture/issues, or the existingtests/eval.rsAPI harness for the Evaluator case. Check exact execution/return values and valid generated syntax, not only snapshots. - Initialize submodules, update fixture expectations only as needed, and rerun
cargo test -p swc_ecma_minifierwithout UPDATE. Preserve passing controls above. Keep regression comments in English.
Duplicate search
No same-root open duplicate was found in bounded searches including "property mangling" and related minifier terms. Similar issues were evaluated by root cause and transformation boundary.
Out of Scope
Unrelated rewrites, new user options, implementing other audit findings, and changing semantic assumptions.
This is a message for readers, not the author of this issue.
Please read no +1 before leaving a comment.
Source: swc-project/swc