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
An if whose arms are fields (if c: x.s else: y.s) joins as a view but still blanks the field — later reads see "" #1409
Spec: §2.2 (a field never moves out implicitly, D32) / D27 ("a binding names what is there"). Split from #1380, which covers arms that are whole bindings.
use std.process
type S { s: str }
fn main:
let x = S { s: "x" ++ "y" }
let y = S { s: "u" ++ "v" }
let c = args().len() > 0
let p = if c: x.s else: y.s
let q = if c: x.s else: y.s
print(f"[{p}] [{q}] [{x.s}]")
Actual (installed v0.15.2.1; also the #1380 branch): compiles, prints [xy] [] [], debug-alloc: leak count=0.
the D32 error "a field never moves out implicitly" at the arm.
Mechanism: lower_if lowers the arm with lower_expr, which moves the field (OK_MOVE of _x.f0) and queues a reset-on-move. flush_pending_resets_since then blanks the field inside the branch. Only after that does last_if_result_view classify the join as a view. So the result is a view of a field that was just blanked. Sema records no move (mark_moved_if_consumed never sees the arm), so nothing is diagnosed.
Activity
Sema: a value `if`/`match` arm that yields a whole binding moves it (#…
Restore Vec.clone in drop-state storage; pin the cross-unit receiver …
Sema/MIR: a join whose arms are all non-Copy field places is a view o…
Sema/MIR: a join whose arms are all non-Copy field places is a view o…