mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
topdown: capture prev function result in the "false" case, too (#5286)
Fixes #5272. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user