Improve rule conflict error
johanfylling opened this issue · 0 comments
johanfylling commented
The following policy:
package play
p := 1
p.q := 2
p.r[s] := 3 { s := "s" }
will generate the error:
1 error occurred: policy.rego:3: rego_type_error: rule data.play.p conflicts with [data.play.p.q data.play.p.r[__local0__]]
This error has two points that can be improved:
- the rewritten var
__local0__
is output instead ofs
for rulep.r[s]
. - no location is given for the conflicting refs
data.play.p.q
anddata.play.p.r[__local0__]
.
(2) might get very verbose if location data is added, especially if a rule is declared over multiple modules. A multi-line error might be appropriate:
1 error occurred: policy.rego:3: rego_type_error: rule data.play.p conflicts with:
rule data.play.p.q at policy1.rego:5, policy2.rego:12
rule data.play.p.r[s] at policy1.rego:7
the above error assumes an additional module that also declares rule play.p.q
on line 12
.