fix(minifier): treat object spread of getters as having side effects#20380
fix(minifier): treat object spread of getters as having side effects#20380
Conversation
Spreading an object literal containing a getter invokes the getter at runtime, so it must be treated as having side effects. The previous logic only checked key/value nodes and missed the getter invocation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the minifier’s side-effect analysis for object spread so that spreading an object literal with a getter is treated as side-effectful (since the getter is invoked at runtime), matching Rollup/Rolldown expectations.
Changes:
- Add regression tests asserting object spread invokes getters (but not setters).
- Update
MayHaveSideEffectsfor object spread to treatgetproperties as side-effectful during spreading.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_minifier/tests/ecmascript/may_have_side_effects.rs | Adds tests for getter/setter behavior when spreading object literals. |
| crates/oxc_ecmascript/src/side_effects/expressions.rs | Updates spread side-effect logic to flag getters as side-effectful during object spread. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6d6b4c301
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merging this PR will not alter performance
Comparing Footnotes
|
### 🐛 Bug Fixes - edb8677 ecmascript: Treat collection constructor with variable arg as side-effectful (#20383) (Dunqing) - 1f65c3f transformer: Emit design:paramtypes when class has static anonymous class expression (#20382) (bab) - fa70d5c transformer: Use implementation signature for design:paramtypes when constructor is overloaded (#20394) (bab) - ed5a7fb parser: Report syntax error for `new super()` (#20384) (Boshen) - e62524d minifier: Treat object spread of getters as having side effects (#20380) (Boshen) - f8fbd6e linter/plugins: Remove `hashbang` property from AST (#20365) (overlookmotel) ### ⚡ Performance - 30a2b0f minifier: Use atom_from_strs_array for template literal concat (#20386) (Boshen) - 690ce17 minifier: Use Vec::with_capacity for inline template expressions (#20389) (Boshen) - 9cd612f linter/plugins: Recycle comment objects (#20362) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Summary
...{ get prop() {} }) invokes getters at runtime, so it has side effectsrollup@function@object-spread-side-effect🤖 Generated with Claude Code