Skip to content

nightly-2024-02-04: fix: allow performing bitwise NOT on unsigned integers (#4229)

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 04 Feb 02:13
· 1479 commits to master since this release
b3ddf10
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

Currently running `bit_not` results in the output

```
$ nargo info --show-ssa
error: u8 cannot be used in a unary operation
  ┌─ /home/tom/Programming/aztec/noir/test_programs/execution_success/bit_not/src/main.nr:3:30
  │
3 │     let not_four_as_u8: u8 = !four_as_u8;
  │                              -----------
  │

error: u32 cannot be used in a unary operation
  ┌─ /home/tom/Programming/aztec/noir/test_programs/execution_success/bit_not/src/main.nr:6:32
  │
6 │     let not_four_as_u32: u32 = !four_as_u32;
  │                                ------------
  │
```

We're unable to perform bitwise nots for unsigned integers (signed is
fine). This PR loosens the check being applied in
`lint_overflowing_uint` so that it only errors for using an unary `-`.

## 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.