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
…5921)
# Description
## Problem
Resolves#5903
## Summary
Now the compiler will check that attribute function callbacks have at
least one argument, that that argument's type matches the corresponding
type, and that remaining arguments also match the types given.
Also previously errors on these callbacks were shown on the function
that had the attribute, instead of on the attribute, likely because
attributes didn't have a Span attached to them: this PR adds that too.
## Additional Context
The error message is still a bit strange because if you have code like
this:
```rust
#[attr]
fn foo() {}
fn attr() {}
fn main() {}
```
You get this:
```
error: Expected 0 arguments, but 1 was provided
┌─ src/main.nr:1:3
│
1 │ #[attr]
│ ---- Too many arguments
```
which kind of makes sense, because 1 implicit argument was provided but
0 are expected in the callback, but maybe the error should point out
that the callback actually needs one argument. Let me know if you think
we should improve the error message here... but at least it doesn't
error anymore.
Oh, I remember why I didn't improve that error message: the error should
likely be on the callback function, but it should point out that the
error happens because of a given attribute, so we need two different
locations for the error, which I think we currently doesn't support.
## 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
The compiler shouldn't panic if an attribute function doesn't have the expected arguments.
Expected Behavior
This code:
should give an error saying that
attr
should have aFunctionDefinition
argument.Similarly, if there's a first argument but it's not a
FunctionDefinition
, it should also error.Bug
No error for the above case.
To Reproduce
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
No response
NoirJS Version
No response
Proving Backend Tooling & 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: