mukul-rathi / bolt

Bolt is a language with in-built data-race freedom!
MIT License
553 stars 53 forks source link

Check consumed vars cannot be referenced subsequently #30

Closed mukul-rathi closed 4 years ago

mukul-rathi commented 4 years ago

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 after consume x).

Currently these are not being caught by the type-checker - resulting in a run-time error.

mukul-rathi commented 4 years ago

Should be done statically in a separate pass - assess which variables + object fields have not been consumed.

mukul-rathi commented 4 years ago

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.__.

mukul-rathi commented 4 years ago

this problem of consume is just like the free() memory problem with dangling ptrs