Closed mukul-rathi closed 4 years ago
Should be done statically in a separate pass - assess which variables + object fields have not been consumed.
This should be conservatively checked e.g.
let y = if true then new Foo() else consume x
....
x // shouldn't be reading x, even though we'd never traverse the else branch
So if x
consumed, then shouldn't read value x
or x.__
.
this problem of consume is just like the free() memory problem with dangling ptrs
Core type-checker should return the updated env after having inferred the type of an expression, since the env may change (e.g.
x
now is a dangling pointer afterconsume x
).Currently these are not being caught by the type-checker - resulting in a run-time error.