diff --git a/test/cases/testdata/functionerrors/test-conflicts.yaml b/test/cases/testdata/functionerrors/test-conflicts.yaml new file mode 100644 index 0000000000..ddd29d18ca --- /dev/null +++ b/test/cases/testdata/functionerrors/test-conflicts.yaml @@ -0,0 +1,21 @@ +cases: +- modules: + - | + package test + o = ["1", "2"] + f(x) := o[_] == x + p { f("1") } + note: 'functionerrors/conflict: plain false and true result, first round' + query: data.test.p = x + want_error: functions must not produce multiple outputs for same inputs + want_error_code: eval_conflict_error +- modules: + - | + package test + o = ["1", "2"] + f(x) := o[_] == x + p { f("2") } + note: 'functionerrors/conflict: plain false and true result, second round' + query: data.test.p = x + want_error: functions must not produce multiple outputs for same inputs + want_error_code: eval_conflict_error diff --git a/topdown/eval.go b/topdown/eval.go index f10252d3a1..50ff72dc41 100644 --- a/topdown/eval.go +++ b/topdown/eval.go @@ -1931,6 +1931,7 @@ func (e evalFunc) evalOneRule(iter unifyIterator, rule *ast.Rule, cacheKey ast.R if prev != nil && ast.Compare(prev, result) != 0 { return functionConflictErr(rule.Location) } + prev = result return nil } }