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

Negative literal generic panics #5552

Closed
michaeljklein opened this issue Jul 18, 2024 · 0 comments · Fixed by #5572
Closed

Negative literal generic panics #5552

michaeljklein opened this issue Jul 18, 2024 · 0 comments · Fixed by #5572
Assignees
Labels
bug Something isn't working

Comments

@michaeljklein
Copy link
Contributor

Aim

Attempted to compile:

// Also panic:
// type Foo = [Field; -1]>;
// type Foo = Bar<-1>;
// type Foo = str<-1>;
struct Foo<let N: i8> { }

fn main() {
    let _: Foo<-1> = Foo { };
}

Expected Behavior

Expected that the struct with a negative constant generic argument would compile successfully and that the types with invalid negative arguments would fail with a user type error.

Bug

The application panicked (crashed).
Message:  Negative literal is not allowed here
Location: compiler/noirc_frontend/src/ast/mod.rs:327

To Reproduce

Project Impact

Nice-to-have

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

Binary (noirup default)

Nargo Version

nargo version = 0.31.0 noirc version = 0.31.0+45e82a672b9ba7f7326e8d9f8800e2489013e2e8 (git version hash: 45e82a6, is dirty: false)

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the bug Something isn't working label Jul 18, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 18, 2024
@vezenovm vezenovm self-assigned this Jul 18, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 20, 2024
# Description

## Problem\*

Resolves #5552

## Summary\*

This temporarily disallows signed numeric generics as to prevent the
panic in the issue until they are fully supported. In general type-level
integers need to be updated to support numeric generics. It is deceiving
to not ban them until type-level integers are updated as otherwise users
can declare signed numeric generics but not actually use them as per the
linked issue.

For the code in the issue we now get this error:
<img width="697" alt="Screenshot 2024-07-19 at 5 41 13 PM"
src="https://github.com/user-attachments/assets/17979de7-8c82-40af-aa0f-a32f73992d48">


## Additional Context



## Documentation\*

Check one:
- [] No documentation needed.
- [ ] Documentation included in this PR.
- [X] **[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.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 20, 2024
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
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants