Skip to content

Commit

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

Fixes #3501.

Signed-off-by: Stephan Renatus <[email protected]>
  • Loading branch information
srenatus authored May 28, 2021
1 parent a57fc72 commit 0a6bf53
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 0a6bf53

Please sign in to comment.