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

Compilation panic: Length of array is unknown when evaluating numeric generic #4407

Closed
LogvinovLeon opened this issue Feb 22, 2024 · 0 comments · Fixed by #4408
Closed

Compilation panic: Length of array is unknown when evaluating numeric generic #4407

LogvinovLeon opened this issue Feb 22, 2024 · 0 comments · Fixed by #4408
Labels
bug Something isn't working

Comments

@LogvinovLeon
Copy link
Contributor

Aim

I've tried to compile this code. I understand that it's incorrect, but it should not cause compiler panic.

fn main() {
    f();
}

pub fn f<NUM_FIELDS>() -> [Field; NUM_FIELDS] {
    [0; NUM_FIELDS]
}

Expected Behavior

I get the compilation error

Bug

I get compiler panic

To Reproduce

  1. Compile the program above wit nargo v0.23.0 or 0.24.0

Project Impact

Blocker

Impact Context

I've had an issue in my tests that the assertion were firing in the wrong order. I saw that it's fixed in 0.24. Tried to upgrade to 0.24, but encountered a compilation panic. Tried to find the minimal example and found the one here which funnily is also happening on 0.23.

Therefore without this fixed I would be stuck on 0.23 and will need to have wrong assertion messages in test expects

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

Binary (noirup default)

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@LogvinovLeon LogvinovLeon added the bug Something isn't working label Feb 22, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 26, 2024
# Description

## Problem\*

Resolves #4407 

## Summary\*

We currently have no way to gracefully error during monomorphization and
so must panic if we run into any errors.

This PR then adds the `MonomorphizationError` enum with an example error
type. We've also added a `CompileError` which unifies `RuntimeError` and
`MonomorphizationError` so they can be converted into `FileDiagnostic`s


## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant