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
Parser/Sema: var (a, b) = ... binds immutable names — the var is dropped for destructuring patterns (§9.7) #1354
Spec §9.7 ("let destructuring"): "All pattern forms are available in let/var bindings." A var destructuring binds immutable names.
fn lc(b: i32) -> (i32, i32): (b + 1, b + 2)
fn main:
var (x, y) = lc(3)
x = x + 10
print(f"{x} {y}")
Actual (seed pinned in seed.lock, and a stage built from fix-stage-debug-info + #1349's fix): error: cannot assign to immutable variable at x = x + 10.
Expected: prints 14 5.
Exact line: Parser.parse_let_binding (src/Parser.w ~7091) computes is_mut and then, for a (/{/[ pattern, calls parse_let_pattern_rest(start, pat), which builds NK_LET_ELSE(pat, value, else_body) with no mutability anywhere; Sema's check_pattern then scope_put(sym, ty, 0) for every NK_PAT_IDENT. The var is dropped at parse time. var Name { .. } = ... (#1299 path) goes through the same parse_let_pattern_rest.
Activity
Sema: a destructuring let, `for` and `with` check their subject as a …
var PATTERN binds mutable names; let PATTERN: TYPE = EXPR parses and …
Sema: a destructuring let, `for` and `with` check their subject as a …
var PATTERN binds mutable names; let PATTERN: TYPE = EXPR parses and …
var PATTERN binds mutable names; let PATTERN: TYPE = EXPR parses and …
var PATTERN binds mutable names; let PATTERN: TYPE = EXPR (§9.7, §30.…
:install-user installs through the .Install kind's placement: temp + …
Sema: an aggregate whose elements differ in representation is a type …
Sema: an aggregate whose elements differ in representation is a type …