Linear closure accesses shared mutable variable of active object
supercooldave opened this issue · comments
It seems that a linear closure that accesses the mutable state of an active object can be passed outside of the active object, creating a potential race condition on the mutable state between the closure and the active object. The following example compiles (though it does not exhibit a race condition), when perhaps it shouldn't.
This problem occurs in the HEAD
of development
.
def main() : unit
val bar = new Bar(10)
val f = get(bar!clo())
println(f(12))
end
end
active class Bar
var foo : int
def init(i : int) : unit
this.foo = i
end
def clo() : linear ((int) -> int)
fun (x : int) : int
this.foo + x
end
end
end