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
for x in xs over a &[T] parameter fails MIR lowering #1197
Spec §13 (iteration): a slice is iterable. A for over a &[T] parameter fails MIR lowering, for T = i32 and T = str alike.
fn show(xs: &[i32]):
for x in xs: print(f"{x}")
fn main:
let a = [1, 2]
show(a[..])
[mir-lower-fail] kind=37 fn=show span=25..46 (WITH_MIR_AUDIT=1; kind 37 = NK_FOR)
error: MIR lowering failed for function 'show' in sl_i.w; AST codegen was removed, so this function cannot be compiled
Sema accepts it; the failure is loud but has no source diagnostic. for i in 0..xs.len(): xs[i] works.
Workaround in use: indexed loop in test/behavior/behav_c_abi_small_structs.w (#1195); restore for line in expected when fixed.
Activity