You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
validate-ownership accepts a move out of a shared reference's pointee (_4 = move _1.*.p through &self) #1415
Tool gap found during #1395 (CLAUDE.md: "a tool that stayed silent is a bug").
Before the #1395 Sema fix, this program compiled and double-freed the Vec:
type S { p: Vec[i32] }
impl S:
fn f(c: bool):
let v = if c: self.p else: Vec.new()
print(v.len())
fn main:
var p: Vec[i32] = Vec.new()
p.push(1)
let s = S { p }
s.f(true)
print(s.p.len())
with check --dump-mir (installed v0.15.2.1) shows the join arm as a move out of the pointee of the shared &S receiver:
bb1: {
_4 = move _1.*.p;
goto -> bb3;
}
and with check --validate-all answers validate-all: ok. The debug allocator reports the double free at run time (rc=134).
validate_ownership_body (src/MirCore.w) checks drop reachability (MaybeGarbage/Uninit) only; nothing rejects an OK_MOVE of a needs-drop place whose projection chain passes through a Deref of a shared reference (TY_REF, d1 == 0). Moving out through a shared reference is never valid MIR: the frame does not own the storage (and cannot reset it). A move through a mut fn receiver's place is the D32 explicit vacate and stays legal.
#1395 closes the Sema hole that produced this shape, but MirLower still emits OK_MOVE for a needs-drop field read through a shared borrow when the value type is not str (lower_expr NK_FIELD_ACCESS, the "#780 residue" comment), so the validator is the backstop that would catch the next Sema gap. Vetting the rule needs --validate-all over the whole test corpus, which is why it is filed rather than landed with #1395.
Activity
validate-ownership: a move out of a place projected through a referen…
validate-ownership: a move out of a place projected through a referen…
validate-ownership: a move out of a place projected through a referen…
validate-ownership: a move out of a place projected through a referen…
validate-ownership rejects vacated payloads and moves through referen…