-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing semantics when adding if ...
to a partial set rule
#6184
Comments
A side effect of this — a trick we use in Regal to distinguish: a { true } from a = true { true } Is to simply check the rule head value for the presence of a This "trick" however breaks for the beforementioned case, as a location for the value is added for the
opa parse --format json --json-include locations p.rego {
"head": {
"value": {
"location": {
"file": "p.rego",
"row": 5,
"col": 1
},
"type": "boolean",
"value": true
}
}
} |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue. |
Can we close this in favor of #6247? |
Sure. Just so that I understand, while we will require a["b"] to become this a contains "b" Without an if added / required. Is that correct? |
Yes! |
From the perspective of a clueless indivdual — and that would be me :) — it is difficult to understand the semantics of these expressions, and how adding
if true
to a rule head would alter the value/type of the rule(!)a["b"]
As expected, this creates a set containing the value "b".
This creates a map with the key
b
and the valuetrue
. That is... not what I expected, as to me theif
ina["b"] if true
would be syntax sugar fora["b"] { true }
, which apparently it isn't.Now, I'm well aware that using
contains
would be the correct way to work with partial sets in ref-head rules, but given how that came out of backwards compatibility concerns, andif
also is a new keyword, it's hard to imagine backwards compatibility being the problem here.The formatter also rewrites
a["b"] if true
->a["b"] = true
which to me is not semantically equivalent. I've tried finding anything on this in the docs but I've come up short.The text was updated successfully, but these errors were encountered: