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.3k stars 42 forks source link

Binary operator checking #92

Open kaleidawave opened 7 months ago

kaleidawave commented 7 months ago

Current the functions to doing binary operations don't check the types of either side. First a bit of background:

There are two functions for binary operators, they are split between

in and instanceof operators are handled specially on Environment

There is a also a current option strict_casts (it should probably be renamed to no_implicit_casts) in TypeCheckOptions. When this is true should not allow operations like "hi" + 2.

These two functions are currently set up to return a Result. However both the logic for checking the sides and the diagnostic has not been implemented. For example

https://github.com/kaleidawave/ezno/blob/502126217170121cadb12cad3debe1ff388a37f1/checker/src/behavior/operations.rs#L76-L84

There are several things to carefully consider here