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
Miscompile: let Some(x) = e else: break inside a loop — the function returns garbage and leaks #1733
Spec: §9.7 (let-else; D58), §13.5d. Found while writing the #1725 tests (branch gen-push-pull); reproduces on the gen-push-impl base and on the installed compiler (main).
Repro:
fn count_to(lim: i32) -> i32:
var n = 0
var out: Vec[i32] = Vec.new()
while true:
let Some(x) = (if n < lim: Some(n) else: None) else: break
out.push(x)
n += 1
out.len() as i32
fn main:
print(count_to(3))
Expected: 3. Actual: a garbage value (78200848, 5455888 — varies per run); with a Vec returned instead of its length, the returned Vec has len 0 and --debug-alloc reports its buffer leaked. The same loop written with match e: Some(x) => ... None => break is correct.
Not yet root-caused (no MIR/lldb work done); the break out of the let-else's else branch appears to skip or misdirect the loop exit — the value after the loop is not the one the body built.
Workaround used: match with a None => break arm (test/behavior/behav_gen_pull_zip.w).
Activity
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (§13.4, …
D69: g.pull() — a generator stepped by next() on its own fiber (#1748)
Sema: a `break` in a let-else's else branch exits its loop — fall-thr…
Ownership: D72 liveness byte, D73 assignment-as-read, validator leak/…