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

ast/compile: check arity in undefined function stage #4059

Conversation

srenatus
Copy link
Contributor

Before, the "undefined function" check stage in the compiler (and query
compiler) only asserted that the function was known.

Now, we'll also check that the number of arguments could be valid. If
it really is valid will be determined by the type checker at a later
stage.

However, asserting the arity early allows us to give more on-the-spot
error messages.

Fixes #4054.

@srenatus srenatus force-pushed the sr/ast/compile-check-arity-when-checking-undefined-functions branch 2 times, most recently from bfb2452 to 19ac7c4 Compare November 29, 2021 11:13
@srenatus srenatus marked this pull request as ready for review November 29, 2021 11:21
Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

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

Let's hold off on merging this until after the release. It would be nice to revisit the type checker and improve it to be order-insensitive so that it could run before the safety check. That's lower priority of course. LGTM.

ast/compile.go Outdated Show resolved Hide resolved
Before, the "undefined function" check stage in the compiler (and query
compiler) only asserted that the function was known.

Now, we'll also check that the number of arguments _could be_ valid. If
it really is valid will be determined by the type checker at a later
stage.

However, asserting the arity early allows us to give more on-the-spot
error messages.

Fixes open-policy-agent#4054.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
@srenatus srenatus force-pushed the sr/ast/compile-check-arity-when-checking-undefined-functions branch from bd6bd89 to f912b48 Compare November 30, 2021 09:20
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
@srenatus srenatus force-pushed the sr/ast/compile-check-arity-when-checking-undefined-functions branch from f912b48 to fa4ad03 Compare November 30, 2021 09:42
@srenatus srenatus merged commit c97f58b into open-policy-agent:main Dec 1, 2021
@srenatus srenatus deleted the sr/ast/compile-check-arity-when-checking-undefined-functions branch December 1, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Providing wrong arity to built-ins should explain actual problem
2 participants