Comparing String and Number in Rego should evaluate to error #50
-
In the styra's opa-rego course's Quiz on iteration for arrays, objects, and sets, there was this one question: # What does 'foo' evaluate to?
n := {"a": 7, "b": 1, "c": 3, "d": 9}
foo {
some i
v := n[i]
i > 7
} and in the answer it is given that:
I did not get that, why Similar thing holds when we compare a boolean with a number. An example in playground: https://play.openpolicyagent.org/p/FAtMFxUVTZ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I agree that this is slightly confusing, and if designed today this could probably have been made an error. Considering how uncommon these types of comparisons likely are, and that changing this now would break existing policies (however uncommon) I don't believe it would be desirable to have this changed now. Good to have this reported here though if others should search for it 👍 |
Beta Was this translation helpful? Give feedback.
I agree that this is slightly confusing, and if designed today this could probably have been made an error. Considering how uncommon these types of comparisons likely are, and that changing this now would break existing policies (however uncommon) I don't believe it would be desirable to have this changed now. Good to have this reported here though if others should search for it 👍