kaleidawave / ezno

A JavaScript compiler and TypeScript checker written in Rust with a focus on static analysis and runtime performance
https://kaleidawave.github.io/posts/introducing-ezno/
MIT License
2.44k stars 45 forks source link

Record mutated variables / objects that might be mutated by a unknown loop or function call #60

Open kaleidawave opened 1 year ago

kaleidawave commented 1 year ago

Given something like

function (cb: Function) {
    const obj = { a: 2 }
    cb(obj)
    console.log(obj.a)
}

This might fail if the function passed as cb deletes a from obj.

As there is no annotation syntax for marking a function as pure/without side effects (at the moment 👀) the safety isn't known inside the function.

This currently isn't caught in Ezno, so needs fixing.

Instead:

kaleidawave commented 9 months ago

95 starts on this might need to identify the edge cases but the basic principal is there