-
Notifications
You must be signed in to change notification settings - Fork 230
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
Integer literal overflow/underflow doesn't always error #5372
Labels
bug
Something isn't working
Comments
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 3, 2024
…5375) # Description ## Problem Resolves #5372 ## Summary Correctly detects overflows/underflows for basic integer types. The sign of a field element value is now also propagated to the ssa phase. But previously, the field value was applied some casting before reaching the ssa phase so checking that value like that was a bit strange. In this PR that conversion is delayed until the ssa phase, and the value can be checked prior to that conversion. ## Additional Context None. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
This was referenced Jul 5, 2024
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 5, 2024
…5416) # Description ## Problem Resolves #5419 ## Summary This is similar to #5372, except that here the compiler does an early check with explicitly annotated types, and in the related issue the check is done later on, once unknown types are resolved. Also in this PR: - a test was moved from `test_programs` to `noirc_frontend/src/tests.rs` because the error produced here can be caught there - the error message produced in both places is now exactly the same (showing the possible range of values, which helps to know why you exceeded the min/max) ## Additional Context None ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aim
The compiler should error when integer literals don't fit the target integer type. This is already done in some cases, but not in all of them and not always correctly. Some examples:
(and similarly for other integer types)
Expected Behavior
This program should fail to compile:
Bug
The program successfully compiles and executing it prints "-128".
To Reproduce
No response
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
None
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
Yes
Support Needs
No response
The text was updated successfully, but these errors were encountered: