fix(es/minifier): Prevent compress.comparisons from transforming expressions with side effects
This commit fixes issue #11255 where the compress.comparisons optimization
was incorrectly transforming comparisons containing expressions with side
effects (like ++PC), changing the program's behavior.
The fix introduces a helper function `contains_update_or_assign()` that
checks if an expression contains update expressions (++, --) or assignments
that would make duplicate evaluations produce different results.
Changes:
- Added `contains_update_or_assign()` helper function in ops.rs and bools.rs
- Updated comparison optimizations to skip expressions with update/assign
- Added test case for issue #11255
The optimization now correctly preserves expressions like:
Stack[Code[++PC]] === Stack[Code[++PC]]
Instead of incorrectly converting them to ==, which would change semantics.
Fixes #11255
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
c25fca5
2 days ago
by github-actions[bot]
-0.02%
fix(es/minifier): Refine side-effect check to only apply when comparing identical expressions
The previous fix was too conservative, preventing valid optimizations.
The side-effect check should only apply when we're treating two expressions
as identical (e.g., `x === x`), not when we're just converting `===` to `==`
based on type compatibility.
This fixes the 23 failing tests while preserving the fix for issue #11255.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
526bbd1
2 days ago
by github-actions[bot]
+0.01%
fix: Remove unused contains_update_or_assign function from bools.rs
This function was no longer being used after refining the side-effect checks.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
49dc58b
2 days ago
by github-actions[bot]
-0.02%
fix: Remove trailing newline in bools.rs to fix cargo fmt check
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
063d2f3
2 days ago
by github-actions[bot]
0%
test(es/minifier): Add missing output.mangleOnly.js for issue #11255 test
Add the missing mangled output file for the issue_11255_side_effects test case.
This file is required by the test framework to verify that the minifier
correctly preserves expressions with side effects during name mangling.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>