-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: Validate argument count #1233
Conversation
a56f7d7
to
e405bbe
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1233 +/- ##
==========================================
- Coverage 91.11% 91.02% -0.09%
==========================================
Files 153 153
Lines 44816 44943 +127
==========================================
+ Hits 40833 40910 +77
- Misses 3983 4033 +50 ☔ View full report in Codecov by Sentry. |
e405bbe
to
ea3e606
Compare
|
||
Note that for `FUNCTION`s the argument count must match with the declared parameters and can be bigger if a variadic | ||
parameter is present. For stateful POUs the argument count can be shorter than the declared parameters or be bigger | ||
**if** variadic parameters are declared. This is because `VAR_INPUT`, `VAR_OUTPUT` arguments are optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Programs and Function blocks do not support variadics, so smaller is allowed but never bigger AFAIK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense, thanks!
a24909b
to
29e96f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very fancy!
} | ||
|
||
Diagnostic::new(format!( | ||
"this POU takes {expected} but {actual} were supplied", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this POU takes 0 arguments but 1 argument were supplied
We could be even more fancy here by changing were to was for single arguments 💅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, now we are at peak fancy level 🕺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be the party p**per but you don't need the check if you say something like
"Expected {x} arguments but got {y}."
Co-authored-by: Michael <78988079+mhasel@users.noreply.github.com>
Co-authored-by: Michael <78988079+mhasel@users.noreply.github.com>
Co-authored-by: Michael <78988079+mhasel@users.noreply.github.com>
Co-authored-by: Michael <78988079+mhasel@users.noreply.github.com>
…lang/rusty into volsa/validate-fn-arguments
Resolves #1027 and #1201