Repository navigation
fix: resolve Moving a may-share peer of a parameter escapes the O5.1 non-owned check (h2 := h; task worker(move h2) — OK accepted, fatal error: concurrent map writes) (#75) - #410
Conversation
…non-owned check (h2 := h; task worker(move h2) — OK accepted, fatal error: concurrent map writes) (limitlessprojects#75)
|
Built your branch locally ( I also tried to break the precision boundary, since fn fresh(h holder) (holder, bool) {
var x holder
x.m = map[string]int{} // fresh map — does not alias h.m
return x, true
}
// h2, ok := fresh(h)
// task worker(move h2)
// h.m["main"]++This rejects with Two small things worth a minute:
Neither blocks the fix — the soundness direction is right and the corpus is clean. |
… multi-return ACCEPT control (limitlessprojects#75)
|
Thanks for verifying against the corpus and for the suggestions @G0st13! Addressed both in e9edf1a:
|
|
Validation (agent session-15/2-a3, worktree = PR head merged with main @ c53978b): VALIDATED — READY TO LAND. Status note: the base repro from #75 (
Positive controls stay green: unpacking a fresh composite ( Battery on the merged worktree: One integration note: this PR and #395 both rework |
|
Thank you for validating @limitlessprojects! Ready to land cleanly on |
Summary
Fixes #75
Moving a
may_sharepeer of a parameter (or receiver / capture / range variable /constcomposite) could still escape the O5.1 / O5.4 non-owned move check (HYB-E3004) in two pathways incompiler/crates/hy-check/src/loans.rs:Shadowing or multi-defining the parameter/root after creating a
may_sharepeer (h2 := h; if true { h := fresh; ... }orh2 := h; h, tag := fresh, 1):rebind_assign_targets, which transfersname'snon_owned_origintost.share_group(name)before callingst.share_clear(name),define_bindingimmediately calledst.aliases.remove(name); st.share_clear(name);without transferringname's non-owned origin to its existingmay_sharepeers or direct alias children.hwas shadowed in an inner block or redefined via a multi-name:=,st.share_clear("h")severed"h"fromst.may_share["h2"]while replacing"h"inst.scopeswith an owned binding (non_owned_origin: None), allowingtask worker(move h2, done)to pass with0 diagnostics (OK)and race with the caller'sh.m.Multi-value unpack defines and assignments from a parameter (
h2, ok := alias_pair(h),h2, ok = alias_pair(h),m, ok := buckets["k"]):l.values.len() == 1 && l.names.len() > 1branch ofprocess_localand thevalues.len() == 1 && targets.len() > 1branch ofrebind_assign_targetsupdated target shapes/types without recordingmay_shareor alias edges from the RHS expression for reference-bearing targets, allowing amay_sharepeer unpacked from a multi-return call or comma-ok map lookup on a parameter to bemoved across atask/<-boundary without triggeringHYB-E3004.Root Cause & Changes (
compiler/crates/hy-check/src/loans.rs)define_binding: Before clearingst.aliasesandst.may_shareforname, checkself.non_owned_origin_of(st, name)and propagatepeer_origin("a may-share peer of ...") to every peer inst.share_group(name)andorigto direct alias children (st.aliasesentries pointing toname) whosenon_owned_originisNone.record_multi_value_share_and_alias(process_local&rebind_assign_targets): Recordmay_shareand alias edges per target binding in multi-value defines (h2, ok := alias_pair(h),m, ok := buckets["k"]) and multi-value assignments (h2, ok = alias_pair(h)) using each target's resolvedTypeShape, while preserving self-shadowed non-owned origins and transferring prior non-owned origins before clearingst.may_share.compiler/crates/hy-check/src/loans.rs:param_may_share_peer_survived_inner_shadow_rejects_with_e3004param_may_share_peer_survived_parallel_redefine_rejects_with_e3004multi_return_define_from_param_rejects_may_share_move_with_e3004multi_return_assign_from_param_rejects_may_share_move_with_e3004comma_ok_map_lookup_on_param_rejects_move_with_e3004Verification
cargo test --manifest-path compiler/Cargo.toml -p hy-check: 131/131 unit tests pass, 86/86 integration tests pass (0 failed).