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
Sema: let (a, b) = if c: f() else: (1, 0) rejected — "tuple pattern requires tuple subject" #1349
Repro (the seed pinned in seed.lock and installed ~/.local/bin/with, main at ae609cd):
fn lc(b: i32) -> (i32, i32): (b + 1, b + 2)
fn main:
let b = 3
let (x, y) = if b > 0: lc(b) else: (1, 0)
print(f"{x} {y}")
Actual: error: tuple pattern requires tuple subject at the let (x, y) line, followed by follow-on "undefined variable" errors for x/y.
Expected: prints 4 5. Both arms have type (i32, i32). let (x, y) = lc(b) compiles, so the tuple pattern is rejected only because the subject is an if expression (the subject's type is apparently not settled when the pattern gets checked). Spec: tuple destructuring in let (§9.7 patterns). An if-expression is an ordinary expression.
Workaround used in fix-stage-debug-info (Codegen.debug_push_lexical_block): bind the tuple to a let lc = ... first, then .0/.1.
Activity
Sema: a destructuring let, `for` and `with` check their subject as a …
Sema: a destructuring let, `for` and `with` check their subject as a …
Codegen: restore the natural destructuring spelling in debug_push_lex…
Codegen: restore the natural destructuring spelling in debug_push_lex…