You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Description
## Problem
Resolves#5583
## Summary
There's a call, `verify_generics_count`, that's supposed to do this
check. The problem is that the `args` given to it are the results of
zipping the struct's generics with the given generics. That will always
produce an `args` the size of the smallest of the two. So, if a struct
doesn't have generics, `args` will end up empty and no error is
produced. However, if a struct has more generics than given, an error
was correctly produced. The solution is to get the actual and expected
numbers before shadowing `args`.
## Additional Context
In Rust this program gives two errors:
```rust
struct Foo {}
impl Foo<T> {}
fn main() { }
```
1. cannot find T in this scope
2. struct takes 0 generic arguments but 1 generic argument was supplied
With this PR, in Noir we'll be just giving one error (the second one).
The reason is that only generics that match the struct generics count
are checked. I thought about changing the code to produce the same
number of errors as Rust... but I didn't know if it was worth it. Here
you'll get the "incorrect generics count" error, so you'll have to fix
that by either removing the generic (solved) or by adding a generic to
`struct Foo` (likely not what you are going to do), at which point
you'll get the other error... so I thought that with just one error it's
good enough.
## Documentation\*
Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[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.
Aim
Compile this program:
Expected Behavior
It should error because
Foo
isn't generic. A similar program in Rust gives two erros:T
in this scopeThis program also doesn't produce any errors:
In Rust:
Bug
The above programs should produce an error.
To Reproduce
No response
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
Related to #5542
Installation Method
None
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: