You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compiler should error when an integer literal is assigned to a variable with an explicit integer type, and that literal is outside the range of the integer.
This is already the case, but only for unsigned integers, but only if positive values exceed the maximum. What's missing:
check that negative values can't be assigned to unsigned integers
check min/max against signed integers
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.
Expected Behavior
All of these programs should error:
fnmain(){let x:u8 = -1;}
fnmain(){let x:i8 = -129;}
fnmain(){let x:i8 = 128;}
Bug
The above programs don't error.
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:
…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.
Aim
The compiler should error when an integer literal is assigned to a variable with an explicit integer type, and that literal is outside the range of the integer.
This is already the case, but only for unsigned integers, but only if positive values exceed the maximum. What's missing:
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.
Expected Behavior
All of these programs should error:
Bug
The above programs don't error.
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: