diff --git a/test/cases/testdata/functions/test-functions-unused-arg.yaml b/test/cases/testdata/functions/test-functions-unused-arg.yaml new file mode 100644 index 0000000000..2d28050574 --- /dev/null +++ b/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: [] diff --git a/topdown/eval.go b/topdown/eval.go index 3c7bca3f4b..54791c4f6c 100644 --- a/topdown/eval.go +++ b/topdown/eval.go @@ -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.