Skip to content
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

fix: No longer error on INT_MIN globals #7519

Merged
merged 11 commits into from
Feb 26, 2025
Merged

fix: No longer error on INT_MIN globals #7519

merged 11 commits into from
Feb 26, 2025

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Feb 25, 2025

Description

Problem*

Resolves #7506
Resolves #7324

This PR also possibly improves some error messages which previously displayed negative integer values as a negated field value (a large number) - these will now show an actual negative sign and integer value. I don't expect this to be a noticeable change however since there's a check on FieldElement::display to just display the value as negative if that value is smaller (in terms of string characters).

Summary*

Allow INT_MIN globals by properly handling negatives by refactoring the frontend to use SignedField instead of FieldElement, bool pairs.

Additional Context

One advantage I noticed while using SignedField was that I was able to refactor several separate conversion functions we had (mostly in the interpreter) from SignedField to various signed and unsigned integer types into one place. Before we had written these conversions several times and some handled INT_MIN properly while others did not. Now there are conversion methods on SignedField itself.

Some future improvements we could do that I did not tackle in this PR:

  • Type::Constant still holds a FIeldElement rather than a SignedField. I think refactoring it to handle negatives was beyond the scope of this PR, although theoretically it should be easier in the future once we have the following point.
  • We have several repeated methods for checking if a field value fits in a desired type. We could refactor these to just one method. (There is at least one in SSA and one for Type::Constant although the later is only on Fields). This feels like something that should be on SignedField itself (sans error reporting).

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@jfecher jfecher requested a review from a team February 25, 2025 18:50
Copy link
Collaborator

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I left a couple of comments.

@asterite
Copy link
Collaborator

Sorry, scrolling through the page or something I clicked "Update branch" though it wasn't needed...

@jfecher jfecher enabled auto-merge February 26, 2025 14:16
@jfecher jfecher added this pull request to the merge queue Feb 26, 2025
Merged via the queue into master with commit 0c0c397 Feb 26, 2025
102 checks passed
@jfecher jfecher deleted the jf/int-min-globals branch February 26, 2025 14:41
TomAFrench added a commit that referenced this pull request Feb 26, 2025
* master:
  fix: No longer error on INT_MIN globals (#7519)
  fix: correctly format trait function with multiple where clauses (#7531)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request Feb 26, 2025
fix: No longer error on INT_MIN globals (noir-lang/noir#7519)
fix: correctly format trait function with multiple where clauses (noir-lang/noir#7531)
chore(ssa): Do not run passes on Brillig functions post Brillig gen (noir-lang/noir#7527)
TomAFrench pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Feb 26, 2025
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
chore!: bump msrv to 1.85.0
(noir-lang/noir#7530)
fix: No longer error on INT_MIN globals
(noir-lang/noir#7519)
fix: correctly format trait function with multiple where clauses
(noir-lang/noir#7531)
chore(ssa): Do not run passes on Brillig functions post Brillig gen
(noir-lang/noir#7527)
END_COMMIT_OVERRIDE

---------

Co-authored-by: guipublic <guipublic@gmail.com>
Co-authored-by: guipublic <47281315+guipublic@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants