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
Slice pattern over &Vec[T] passes Sema, then invalid MIR (match and let-else) #1389
A slice pattern over a &Vec[T] subject is accepted by Sema and then fails MIR validation, in both match and let ... else (§9.7 slice destructuring, §30.6 SLICE_PAT). Arrays ([4]i32) work (test/behavior/behav_let_else_slice_rest_binding.w).
fn g(v: &Vec[i32]) -> i32:
match v:
[first, ..] => first
_ => -1
fn main:
var a: Vec[i32] = Vec.new()
let b: Vec[i32] = Vec.new()
a.push(4)
print(f"{g(a)} {g(b)}")
Actual (stage1 of origin/fix-1354-var-destructure-mut a7e2004, same on the seed):
error: invalid MIR before codegen: use rvalue does not resolve to a concrete MIR type (place local=2 local_ty=941 projs=1 proj0_kind=0)
--> slm.w:3:9
3 | [first, ..] => first
Expected: 4 -1. let [first, ..] = v else: return -1 fails the same way. Either the pattern is lowered over the Vec's elements or Sema rejects it with a diagnostic; an invalid-MIR ICE is neither. Found while building the #1373/#1382 let-else matrix.
PR #1405 (#1388) makes MirLower's pattern-test default loud: a slice pattern over a subject that is not a fixed-size array now fails MIR lowering with "pattern kind 113 has no match-test lowering". Before, it fell into an accept-everything goto, so match s: [] => ..., [a] => ... over a []i32 silently took the first arm. The lowering itself is still this issue's job.
Activity
ehartford commentedon Sep 23, 2026
PR #1405 (#1388) makes MirLower's pattern-test default loud: a slice pattern over a subject that is not a fixed-size array now fails MIR lowering with "pattern kind 113 has no match-test lowering". Before, it fell into an accept-everything goto, so
match s: [] => ..., [a] => ...over a[]i32silently took the first arm. The lowering itself is still this issue's job.Patterns: a struct pattern tests its literal fields; exhaustiveness r…
Restore Vec.clone in drop-state storage; pin the cross-unit receiver …
Patterns: a struct pattern tests its literal fields; exhaustiveness r…
Slice patterns over a Vec, a slice or a borrowed array bind element v…
Slice patterns over a Vec, a slice or a borrowed array bind element v…
ehartford commentedon Sep 26, 2026
Verified fixed on main 55739d4 (release binary): slice pattern over &Vec[i32] runs, prints 4 -1.