umka-lang
umka-lang copied to clipboard
Weird escape analysis
A temporary "reference holder" variable that stores a function result may be attached to a reference cycle and therefore never freed.
type T = struct {
next: ^T
}
fn foo(n: T): T {
n.next = &n
return n
}
fn bar() {
foo(T{})
} // Runtime error: Pointer to a local variable escapes from the function
fn main() {
bar()
}
Isn't this related to #200
@skejeton I think you mean #199. Yes, it's related, but not the same. There are many ways to produce a reference cycle involving a local variable. What distinguishes the current issue is that a user cannot even see this variable.