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
A second if c: a else: b over the same owned strs reads "" — no diagnostic, no view #1380
Spec: §3.8 / D27 ("a binding names what is there"). Either the first if moved a/b (then the second read is a use of a possibly-moved value and must be rejected), or it yielded a view (then the second read must see the text). It does neither.
use std.process
fn main:
let a = "x" ++ "y"
let b = "u" ++ "v"
let c = args().len() > 0
let p = if c: a else: b
let q = if c: a else: b
print(f"[{p}] [{q}]")
Actual (installed v0.15.2.1, origin/main 8c859a7): compiles, prints [xy] [], debug-alloc: leak count=0.
Expected: [xy] [xy] (view join) or a use-after-move diagnostic on line 7.
The same shape in a loop (for k in 0..2: let p = if k == 0: a else: b) is also accepted, while the unconditional let p = a in a loop is correctly rejected ("moved inside a loop").
Found while writing the #1363 matrix generator (a let p = if path == "err": missing else: (if small: small_path else: huge_path) inside a loop silently produced "" paths). Workaround there: .clone() each arm.
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 …