Semantic Diff

#9538 Remove the handling of assigned variables before sroa

2 commits

6883faf3c0911b9edc07bab07064fda716483b81..pr-9538

97881820b · cknitt + Claude · Dec 05, 2026, 10:09 UTC

Remove the alias pass's tracking of assigned variables

Why

#9424 taught the alias pass and two helpers about Lassigns in bodies inlined from other modules: the pass collected the variables such a body assigns, Lam_bounded_vars.rewrite renamed the assigned variable, and Lam_pass_collect recorded nothing for a mutable let. Since a body that updates a local ref is no longer stored (warning 113), no inlined body assigns a variable, and only Lam_pass_sroa, which runs after every inlining pass, makes Lassigns. Lam_check.check checks this after each pass before sroa under -check-lam, which the compiler tests use. So the set was always empty, no inlined body had an assignment to rename, and no mutable let existed when the facts were collected. The code goes, and Lam_bounded_vars.rewrite now fails on an assignment instead of renaming it. The generated JavaScript doesn't change.

Review

  • Why not keep renaming the assignment, in case? A body with an assignment that reaches inlining is already a bug: the passes before sroa would move reads of the variable past it. Failing there names the variable.
fb365099f · cknitt + Claude · Dec 05, 2026, 10:12 UTC

Stop passing assigned variables through the Lambda analyses

Why

delay_safe, motion, refine_let, the beta reductions, the let pass, the occurrence count and deep_flatten took the set of variables some Lassign assigns, and each caller computed it from the term. All of them run before Lam_pass_sroa, the only pass that makes Lassigns, and Lam_check.check checks under -check-lam that no pass before sroa makes one. So the set was always empty.

Sroa itself kept a set of the fields it had turned into assigned variables, for the refine_let of a read-only field. That field's initializer runs before its block exists, so it can't read or change a field this pass assigns: those are bound in the block's body or inside the initializer. Blocks are replaced from the inside out, so a field of an enclosing block is still a record field there, which delay_safe already takes to change. The set made no difference there either.

The argument goes, and a variable counts as unchanging in these analyses. Lam_stats.assignable, which the JavaScript generation and the JavaScript passes use after sroa, stays. The generated JavaScript doesn't change.