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
We (@FuzzingLabs) find that the compiler incorrectly raises an error when comparing the index of a "for" loop with a non-casted value.
Expected Behavior
The compiler should not treat the compared value as a field type but as a u64
Bug
This error seems to be caused by the compiler treating the compared value as a field type, while the index of a 'for' loop is always treated as a u64, as stated here in the documentation: https://noir-lang.org/docs/noir/syntax/control_flow
As indicated in the code comments, this error doesn't appear with a u64 variable, and it specifically occurs when using the '>'; '<'; ‘≥’; ‘≤’ operators."
The panic crash occurs with the latest compiler version of the main branch. The error message is as follows:
error: Comparisons are invalid on Field types. Try casting the operands to a sized integer type first
To Reproduce
Create a Noir project with the following command: nargo new test_issue
Paste the code below into the file main.nr
Compile the project using the following command: nargo compile
fnmain(){// Raises an error because the compiler interprets '1' as a Field and not as a u64.for i in0..10{assert(i > 1);}// Same issue persists even if the value is stored in a variable.for i in0..10{let val = 1;assert(i < val);}// Error only occurs with '<' '>' '<=' '>=' operators.for i in0..10{assert(i == 1);}// Error only occurs with the index of a "for" loop, not with every u64.let i:u64 = 5;assert(i > 1);// Casting the value as u64 resolves the problem.for i in0..10{assert(i < 1asu64);}}
Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered:
# Description
## Problem\*
Resolves#3639Resolves#4193
## Summary\*
Uses the new TypeVariableKind::Integer in for loops and bitwise
operations to prevent `Field` types from being used there.
Removes the old `delayed_type_checks` hack.
## Additional Context
## Documentation\*
Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** 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.
---------
Co-authored-by: kevaundray <kevtheappdev@gmail.com>
Co-authored-by: TomAFrench <tom@tomfren.ch>
Aim
We (@FuzzingLabs) find that the compiler incorrectly raises an error when comparing the index of a "for" loop with a non-casted value.
Expected Behavior
The compiler should not treat the compared value as a field type but as a u64
Bug
This error seems to be caused by the compiler treating the compared value as a field type, while the index of a 'for' loop is always treated as a u64, as stated here in the documentation: https://noir-lang.org/docs/noir/syntax/control_flow
As indicated in the code comments, this error doesn't appear with a u64 variable, and it specifically occurs when using the '>'; '<'; ‘≥’; ‘≤’ operators."
The panic crash occurs with the latest compiler version of the main branch. The error message is as follows:
To Reproduce
nargo new test_issue
main.nr
nargo compile
Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: