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: canonicalize arithmetic generics in array lengths #6494

Closed

Conversation

TomAFrench
Copy link
Member

@TomAFrench TomAFrench commented Nov 11, 2024

Description

Problem*

Resolves #6495

Summary*

We're getting build failures in AztecProtocol/aztec-packages#9769 due to not being able to solve [Field; (N - 1) + 1] to [Field; N]. This PR adds a unit test showing a case which we should be able to simplify but aren't.

Additional Context

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.

@TomAFrench TomAFrench changed the title chore: add regression unit tests for failing canonicalization fix: canonicalize arithmetic generics in array lengths Nov 11, 2024
…zation

* master:
  chore: move tests for arithmetic generics closer to the code (#6497)
@TomAFrench TomAFrench requested a review from a team November 11, 2024 14:51
@TomAFrench
Copy link
Member Author

@asterite Can you take a look at this? This is blocking a Noir sync atm.

Comment on lines +114 to +117
Type::Array(length, element) => Type::Array(
Box::new(length.canonicalize_helper(found_checked_cast, run_simplifications)),
element,
),
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see what this does but can you elaborate why it was added? The intent of canonicalize was to only work on numeric types. If we start trying to find and canonicalize types recursively like this we're missing a bunch of cases, e.g. numerics in struct generics, handling type variables, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see this is blocking a sync but I still want to ensure its the right solution before just merging it

@TomAFrench
Copy link
Member Author

Yeah, thinking this probably isn't the way to go on second thoughts. The unit test is almost certainly not reflecting what's in the sync.

@TomAFrench TomAFrench closed this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arithmetic generics cannot simplify [Field; (N-1) + 1] to [Field; N]
2 participants