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

topdown: deal with default functions #3505

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/wasm/sdk/test/e2e/exceptions.yaml
@@ -1 +1,2 @@
# Exception Format is <test name>: <reason>
"functions/default": "not supported in topdown, https://github.com/open-policy-agent/opa/issues/2445"
21 changes: 21 additions & 0 deletions test/cases/testdata/functions/test-functions-default.yaml
@@ -0,0 +1,21 @@
cases:
- data:
modules:
- |
package p.m

default hello = false

hello() = m {
m = input.message
1 == 2
m = "world"
}
h = m {
m = hello()
}
note: functions/default # not supported but shouldn't panic
query: data.p.m = x
want_result:
- x:
hello: false
Expand Up @@ -7,6 +7,6 @@ cases:
f(x) {
r = input.that_is_not_there
}
note: basic call
note: unused arg
query: data.p.f(1)
want_result: []
4 changes: 3 additions & 1 deletion topdown/eval.go
Expand Up @@ -1506,7 +1506,9 @@ func (e evalFunc) eval(iter unifyIterator) error {
return err
}

if ir.Empty() {
// default functions aren't supported:
// https://github.com/open-policy-agent/opa/issues/2445
if len(ir.Rules) == 0 {
return nil
}

Expand Down