20260514 tricky cse assign - #482
Merged
Merged
Conversation
prozacchiwawa
marked this pull request as ready for review
May 18, 2026 16:04
Co-authored-by: arty <prozacchiwawa@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3accfbc. Configure here.
aqk
previously approved these changes
May 26, 2026
aqk
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Because this would have kept programs from compiling, this does not need to be feature gated.
Note
Medium Risk
Changes compiler optimization semantics for assign/CSE interaction; incorrect ceiling logic could skip valid CSE or still miscompile, though new tests lock in the reported breakage case.
Overview
Fixes common subexpression elimination (CSE) incorrectly hoisting shared code above
assign/ let bindings when one occurrence lives in a binding that depends on other names in that form (e.g.BusesAwhile(+ A 1)is also duplicated in the assign body).detect_common_cse_rootnow takes an optional ceiling path and returnsOption: it refuses a root above a containing assign body that still provides names the subexpression needs, or when the only common root would sit above that ceiling.cse_optimize_bodyformcomputes that ceiling via newmatch_bindings(names in the duplicated expr ∩ names bound by enclosing lets) and skips the CSE rewrite when no safe root exists.Adds regression coverage: unit test for ceiling rejection,
cse-complex-2.clsp, andtest_cse_breakage_example_lift_outside_bindings(compile + run expects1).Reviewed by Cursor Bugbot for commit 5cfd027. Bugbot is set up for automated code reviews on this repo. Configure here.