Skip to content

Commit

Permalink
topdown: move arg count below ir.Empty()
Browse files Browse the repository at this point in the history
...to avoid a panic at run time.

Fixes open-policy-agent#3501.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
  • Loading branch information
srenatus committed May 28, 2021
1 parent a57fc72 commit b6044b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions test/cases/testdata/functions/test-functions-unused-arg.yaml
@@ -0,0 +1,12 @@
cases:
- data:
modules:
- |
package p
f(x) {
r = input.that_is_not_there
}
note: basic call
query: data.p.f(1)
want_result: []
4 changes: 2 additions & 2 deletions topdown/eval.go
Expand Up @@ -1506,12 +1506,12 @@ func (e evalFunc) eval(iter unifyIterator) error {
return err
}

argCount := len(ir.Rules[0].Head.Args)

if ir.Empty() {
return nil
}

argCount := len(ir.Rules[0].Head.Args)

if len(ir.Else) > 0 && e.e.unknown(e.e.query[e.e.index], e.e.bindings) {
// Partial evaluation of ordered rules is not supported currently. Save the
// expression and continue. This could be revisited in the future.
Expand Down

0 comments on commit b6044b8

Please sign in to comment.