-
Notifications
You must be signed in to change notification settings - Fork 204
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
Incorrect type inference for bit_not
on unsigned integer
#2548
Labels
Comments
Confirming this issue still exists in master. |
There's a good chance this is fixed by @michaeljklein's recent work. Will check today. Edit: it wasn't |
Reopening to add a regression test. |
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 23, 2024
# Description ## Problem Resolves #2548 ## Summary Just adds a regression test. ## 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 return type of the
bit_not
operator is not correctly inferred when used on an unsigned integer.Given the statement:
The type of
3
is inferred to beField
, and the type of!1
is inferred to bebool
. Both of these are incorrect. The compiler throws an error message complaining that the&
operator is operating on two imcompatible types:Field
andbool
.Without the
!1
part, i.e.,let a: u32 = 3 & 1;
, the compiler correctly infers all the data types and the compilation succeeds.Expected Behavior
The compiler should correctly handle the bitwise not operator and infer the type as unsigned integer.
Bug
Run
nargo new bit_not
and replace the contents ofsrc/main.rs
with the following:Run
nargo check
and observe the following error message:To Reproduce
nargo new bit_not
and replace the contents ofsrc/main.rs
with the code above.nargo check
.Installation Method
Binary
Nargo Version
nargo 0.10.5 (git version hash: 9fe4cfd, is dirty: false)
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: