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 capturing self in a read-mode fn method segfaults when called #2025
A closure that reads self.field inside a read-mode fn method crashes (SIGSEGV, rc=139) when it is called through a fn(..) parameter or a pipeline map. The same closure in a mut fn or move fn method works. Found while writing the #1930 fixtures; reproduces on the pinned seed and the installed compiler (main c884c1c).
fn apply(f: fn(i32) -> i32, x: i32) -> i32: f(x)
type C {
count: i32,
}
impl C:
fn plus(x: i32) -> i32: apply(y => y + self.count, x)
fn main:
let c = C { count: 5 }
print(f"{c.plus(3)}")
Expected: 8. Actual: segfault (rc=139), no output. let n = self.count before the closure, then capturing n, prints 8. mut fn plus / move fn plus print 8. self.items.iter() |> map(it + self.count) |> collect[Vec]() in a fn method also segfaults.
Workaround in the #1930 fixture: the closure case is exercised in mut fn / move fn methods; the fn case waits on this fix.
Activity
Codegen: a by-place capture of a read receiver is a slot holding its …
Codegen: a by-place capture of a read receiver is a slot holding its …
Codegen: a by-place capture of a read receiver is a slot holding its …
Codegen: a by-place capture of a read receiver is a slot holding its …