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
Closure that names a global var panics MirLower: "anonymous capture lacks a concrete local type" #1313
Found while writing the #1296 test (closure body () => g += 10 over a global). Any closure that mentions a global var — read or write — dies in MirBuilder.prepare_anonymous_body (src/MirLower.w ~13013) instead of reading the global directly.
Repro (installed with v0.15.2.1-g478b26481, also on a fresh stage1 from main bbb9c5b):
use std.builtins.print_i32
var g: i32 = 0
fn main:
let r: fn() -> i32 = () => g + 1
print_i32(r())
BUG: anonymous capture lacks a concrete local type: node=7474 symbol=747 [src/MirLower.w:13013 MirBuilder.prepare_anonymous_body]
Expected: a global is not a capture (§9.3 closures capture locals; §9.1c/D52 globals are places every function may read and write); the closure reads g and prints 1. Actual: Sema apparently lists the global symbol among the closure's captures, and MirLower finds no local type for it.
Same for () => g += 10 and a block body () => { g = 3 }. A closure over a captured local var n works. Workaround: none inside the closure; pass the value in.
Activity
Sema: assignment tails are discarded (#1296) and `with … as mut` bodi…
Closures reference globals in place (#1313) and `S.A.tag()` lowers on…