Repository navigation
fix(hy-check): propagate moved alias and may_share state across block scope exit and loop back-edges (#313, #399, #253) - #401
Conversation
|
Validation (agent session-15/2-a3, worktree = PR head merged with main @ c53978b): VALIDATED — READY TO LAND. Status note first: the headline repro from #313 (
Positive controls stay green: loop-local fresh map moved per iteration accepts, direct Battery on the merged worktree: Merge-order recommendation: land this PR first; #400 (same model.rs |
|
Thank you for validating @limitlessprojects! Confirmed ready to land cleanly on |
2bb6951 to
e701ebb
Compare
a4ab434 to
ef8280c
Compare
|
Rebased cleanly onto current
Verified: all 134 |
ef8280c to
869f9aa
Compare
869f9aa to
cbe9696
Compare
…lessprojects#313) inner_root_moves is already filtered by survives_as_outer. The extra popped_scope guard skipped block self-shadowing such as 'h, ok := alias_pair(h)', so moving the inner h no longer froze the outer h and main's multi_value_self_redefine_and_shadow_preserves_share_and_alias_edges test failed in CI. All limitlessprojects#313 tests still pass.
Integrate pr-254 (limitlessprojects#253): adopt main's loop back-edge implementation in freeze.rs (block_has_continue_for_loop, the Iterate collection use and the Range hi-only back-edge check with its integration note), and keep only limitlessprojects#313's remaining pieces: shadow seeding for the loop variables and share-group peer/alias clearing. Drop the now-duplicate block_has_direct_continue helpers and the unreachable Iterate arm.
…xit outer aliases Instantiate generic function and method return shapes and TypeExprs from call-site arguments across single-value and multi-value calls so shallow-copied references, struct field projections, slice element copies, and closure slices cannot escape O5.2 freeze tracking. Also preserve surviving outer alias and self-shadow links across FnState::scope_pop and clear alias chains across loop back-edge share groups. Fixes limitlessprojects#73 Fixes limitlessprojects#313 Sibling-take credit: @Visional-Dev (limitlessprojects#408), @Andrrewss (limitlessprojects#401)
/claim #313
Closes #313
Root Cause Analysis (
check_loop_backedge&FnState::scope_pop)In
compiler/crates/hy-check/src/freeze.rs(Checker::check_loop_backedge) andcompiler/crates/hy-check/src/model.rs(FnState::scope_pop), moved alias andmay_sharestate failed to propagate across loop back-edges in three interacting ways:iter_st.scopes.truncate(outer_depth)bypassedFnState::scope_pop():At the end of a loop body (
idx == loop_end),check_loop_backedgetruncatediter_st.scopesdirectly instead of popping inner loop scopes viaiter_st.scope_pop(). Becausealias_scopesandshare_scopeswere not popped andscope_pop()'s shadow-exit freeze propagation did not run oniter_st, any outer aliasalias := mthat was shadowed inside the loop body beforemove mlost its"alias" -> "m"link inst.aliasesand remainedmoved: Noneon the back-edge, allowingaliasto be mutated or moved again at the top of the next iteration with zero diagnostics.Stmt::Localhandling incheck_loop_backedgeclobbered outer bindings:While walking the flattened
loop_stmts,check_loop_backedgetreated everyStmt::Local(l)(for name in &l.names { iter_st.aliases.remove(name); b.moved = None; }) as if it permanently re-owned the outer binding for the remainder of the loop body—even whenStmt::Localoccurred inside a nested block (if i == 0 { alias := 1; ... }) whose scope exited beforetask worker(move alias, done).may_sharerebinds inside inner blocks were dropped onscope_pop():When two outer bindings were linked inside a conditional block (
if i == 0 { alias = m }),scope_pop()restoredouter_aliases/outer_sharewithout preserving outer-to-outer edges (!popped_scope.contains_key(a) && !popped_scope.contains_key(&root)), andmark_movedid not expandst.aliaseschains anchored atmay_sharepeers.Minimal Fix
compiler/crates/hy-check/src/freeze.rs:iter_stviawhile iter_st.scopes.len() > outer_depth { iter_st.scope_pop(); }and resolve roots againstiter_st.loop_bodyviawalk::flatten(loop_body)(ScopeEvent::Push/Pop/SelectRecv) instead of mutatingiter_st's outer bindings and alias map when walking innerStmt::Localdefinitions.may_sharepeers in bothmark_moveandcheck_loop_backedge.compiler/crates/hy-check/src/model.rs:may_shareedges acrossscope_pop()and guardinner_root_movesagainst inner shadow bindings defined inpopped_scope.compiler/crates/hy-check/src/lib.rs:move aliasin a loop, shadowed outer alias propagation across iterations, conditional outer alias rebind in a loop, and a positive control where moving a loop-local shadow does not freeze an untouched outer map.Verification
cargo test --manifest-path compiler/Cargo.toml -p hy-check: 121/121 unit tests + 86/86 integration tests pass (0 failed).Fixes #253
/claim #253