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

Require more precise type resolution in binary operation #257

Open
katat opened this issue Jan 4, 2025 · 2 comments
Open

Require more precise type resolution in binary operation #257

katat opened this issue Jan 4, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@katat
Copy link
Collaborator

katat commented Jan 4, 2025

In type checking phase, the type of a binary operation expression is only determined by the left hand side:

Op2::Addition

However, in the following case, it can mistakenly seen a non constant expression as constant;

fn is_not_constant(val: Field) -> Field {
    // val can be non constant
    return 1 + val;
}

1 + val can be a non constant field type as val can be a non constant.
Therefore, when computing the types for the binary operations, it should take cares of the both sides.

@katat katat added the bug Something isn't working label Jan 4, 2025
@mimoo
Copy link
Contributor

mimoo commented Jan 16, 2025

mmm interesting, wondering if that means that "constant" shouldn't be in the type

@katat
Copy link
Collaborator Author

katat commented Jan 17, 2025

yeah, I think we still need to propagate whether it is a constant or not. For example, the functions support const attribute that enforce the argument to be constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants