Repository navigation
fix(hy-check): scope aliases across blocks, break alias cycles, and reject same-stmt double moves (#31) - #32
Conversation
|
PR #32 (issue #31: shadowed outer alias roots survive block scope) — triage update: Verified on current main (b4c6a68): the repro still accepts with 0 diagnostics, so the underlying gap is REAL and this report stands. Why it is not merged yet: main's alias/freeze machinery moved substantially since this PR's base (record_alias for call-return aliases #38, may-share edges for #27, the non-owned-move guard, parallel pre-state assignment evaluation, multi-event scoping). The PR now conflicts in every touched region of loans.rs/model.rs, and merging it as-is would silently revert those seams. Path forward (maintainer): rebase onto current main and re-apply the fix on top of the new recorders — the repro tests are the acceptance bar, plus cargo/corpus/differential green. The report keeps its bounty standing; this is a rebase ask, not a rejection. |
8d9c9ba to
71518b1
Compare
|
@limitlessprojects Updated (
|
…, and reject same-statement double moves (limitlessprojects#31) Maintainer-assisted rebase onto 8fb9238 (the pr-35/pr-49/pr-56/pr-59/pr-61 seam). Verified on main before the rebase — three of the four holes still reproduce: shadowed-define wipes the outer alias link (u1: if { m2 := 1 } unfixes m2->m), same-statement double-move (u3: task both(move m, move m) accepts), and same-statement move-plus-read (u4: a, b := move m, m accepts). The mutual- rebind cycle (u2) already rejects on main via the pr-35 may-share edges, and the shadowed-root variant (u5) likewise — the PR's tests now pin both. Seam resolution: the PR's machinery applies as authored (alias_scopes snapshots, scope-pop move propagation, cycle-canonical resolve_alias, same-statement stmt_moves in check_uses), extended symmetrically for the seam's SECOND freeze map — may_share gets the same snapshot/restore discipline (share_scopes), because main's freeze verdicts ride pr-35's share edges and the shadow-define's share_clear must not survive the block either. Tests: +3 (shadow-scope alias survival, cycle freeze, same-statement moves incl. the shadowed-root variant); verified on the rebased commit: cargo 293/0, clippy 0, corpus 27/27, differential FULL, examples 10/10.
71518b1 to
249f253
Compare
|
Maintainer-assisted rebase landed — the branch now sits on current Verified on
The mutual-rebind cycle ( Seam resolution: your machinery applies as authored (alias-scope snapshots, scope-pop move propagation, cycle-canonical Verified on the rebased commit: cargo 293/0 · clippy 0 · corpus 27/27 · differential FULL (10/10 + 17/17) · examples 10/10. The report remains bounty-standing — confirmed at triage, now closed by your work. |
Fixes #31
Participates in #5
Problem
FnState.aliaseswiped by block shadowing: Commit2e79213([soundness] inner block shadowing hides an outer map from the task sendability check #14) scopedFnState.envviaFnState.scopes, butFnState.aliasesremained a flatHashMap<String, String>. An inner shadowif true { m2 := 1 }calledst.aliases.remove("m2"), permanently erasing the outerm2 -> malias link so movingmafterward left outerm2unfrozen.m2 := m; m = m2):process_assigninserted"m" -> "m2"while"m2" -> "m"was still present. Becauseresolve_aliasstepped a fixed 16 iterations,resolve_alias(st, "m") == "m"andresolve_alias(st, "m2") == "m2", causingmark_moveto missm2whenmwas moved.task both(move m, move m),a, b := move m, move m,a, b := move m, m):check_usesran once before statement move marking and did not track intra-statement moves on the same alias group, allowing a single statement to duplicate or concurrently share a moved map with0 diagnostics.Fix
compiler/crates/hy-check/src/model.rs:alias_scopes: Vec<HashMap<String, String>>toFnState(saved onscope_push, restored onscope_popwith freeze synchronization across restored alias groups).FnState::detach_alias_bindingto cleanly re-parent dependent aliases when a binding is shadowed or rebound.compiler/crates/hy-check/src/freeze.rs:resolve_aliascycle-canonical and track intra-statement move transfers incheck_usesso double-moves and same-statement move+read emitHYB-E3003(A1b).compiler/crates/hy-check/src/loans.rs:detach_alias_binding, and propagate priormovedstate across multi-defines/rebinds.compiler/crates/hy-check/src/lib.rs:scope_pop()at function exit and add regression tests (shadow_scope_does_not_wipe_outer_alias_e3003,mutual_alias_rebind_cycle_still_freezes_on_move_e3003,same_statement_double_move_and_move_plus_read_reject_e3003).Verification
cargo test -p hy-check— 53/53 unit tests + 2/2 spike6 tests pass.python3 tools/corpus_harness.py --bin compiler/target/debug/hyb— 24/24 verdict agreement, tripwire not fired.