Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary operator checking #92

Open
kaleidawave opened this issue Nov 27, 2023 · 0 comments
Open

Binary operator checking #92

kaleidawave opened this issue Nov 27, 2023 · 0 comments
Labels
checking Issues around checking enhancement New feature or request good-second-issue Moderately difficult issue
Milestone

Comments

@kaleidawave
Copy link
Owner

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

  • Mathematical and bitwise operations. Both sides have to be checked as there is no short circuiting behavior
  • Logical operators. These can have logical operators (and in the future the RHS can be narrowed for && operations)

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

pub fn evaluate_mathematical_operation(
lhs: TypeId,
operator: MathematicalAndBitwise,
rhs: TypeId,
types: &mut TypeStore,
strict_casts: bool,
) -> Result<TypeId, ()> {
fn attempt_constant_math_operator(
lhs: TypeId,

There are several things to carefully consider here

  • Still want to enable Symbol.toPrimative behaviour with hints and such (that will require these functions to have all the context to be able to do a call_type
    • This should disallow Object.toPrimative fall through as this result are not useful
@kaleidawave kaleidawave added enhancement New feature or request good-second-issue Moderately difficult issue checking Issues around checking labels Nov 27, 2023
@kaleidawave kaleidawave added this to the 0.1.0 milestone Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checking Issues around checking enhancement New feature or request good-second-issue Moderately difficult issue
Projects
None yet
Development

No branches or pull requests

1 participant