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

feat: Validate argument count #1233

Merged
merged 20 commits into from
Jun 17, 2024
Merged

feat: Validate argument count #1233

merged 20 commits into from
Jun 17, 2024

Conversation

volsa
Copy link
Member

@volsa volsa commented Jun 4, 2024

Resolves #1027 and #1201

@volsa volsa force-pushed the volsa/validate-fn-arguments branch from a56f7d7 to e405bbe Compare June 4, 2024 13:06
Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.02%. Comparing base (be78df6) to head (02a00dd).
Report is 36 commits behind head on master.

Current head 02a00dd differs from pull request most recent head 31987fa

Please upload reports for the commit 31987fa to get more accurate results.

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.
📢 Have feedback on the report? Share it here.

@volsa volsa force-pushed the volsa/validate-fn-arguments branch from e405bbe to ea3e606 Compare June 4, 2024 13:15

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.
Copy link
Collaborator

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

Copy link
Member Author

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!

@volsa volsa force-pushed the volsa/validate-fn-arguments branch from a24909b to 29e96f4 Compare June 5, 2024 08:31
@volsa volsa marked this pull request as ready for review June 5, 2024 08:33
@volsa volsa requested review from ghaith and mhasel June 5, 2024 08:33
Copy link
Member

@mhasel mhasel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very fancy!

src/index.rs Outdated Show resolved Hide resolved
src/validation/statement.rs Outdated Show resolved Hide resolved
src/validation/statement.rs Outdated Show resolved Hide resolved
src/validation/statement.rs Outdated Show resolved Hide resolved
}

Diagnostic::new(format!(
"this POU takes {expected} but {actual} were supplied",
Copy link
Member

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 💅

Copy link
Member Author

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 🕺

Copy link
Collaborator

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}."

volsa and others added 9 commits June 7, 2024 12:01
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>
@volsa volsa merged commit 8d0e9e5 into master Jun 17, 2024
15 checks passed
@volsa volsa deleted the volsa/validate-fn-arguments branch June 17, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants