-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add (*TemplateString).Copy() method
#8159
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
Add (*TemplateString).Copy() method
#8159
Conversation
Also: - Add `(*TemplateString).Equal()` because why not. - Update `x.Compare(y) == 0` to instead use `x.Equal(y)` where possible Fixes open-policy-agent#8158 Signed-off-by: Anders Eknert <[email protected]>
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
srenatus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
| // case interface{ Equal(Value) bool }: | ||
| // return v.Equal(b) | ||
| // | ||
| // When put on top, golangci-lint even flags the other cases as unreachable.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this somehow get answered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think I managed to make some sense of it, but adding a comment about that would have been odd 😄
The issue is that the vcKeyScope type from eval.go qualifies as a Value, and one that implements its own Compare method that gets called in the fallback condition of this switch. It does not implement its own Equal method, but the type embeds a Ref which does implement Equal. So when we replace the specific types with a check for Equal(Value) bool implementations, the vcKeyScope type is no longer compared using its tailor-made comparison function, but that of a generic ref, and that naturally fails.
Adding a distinct Equal implementation for vcKeyScope would fix this, and perhaps we should.. but that's for another PR 🙂
Also: - Add `(*TemplateString).Equal()` because why not. - Update `x.Compare(y) == 0` to instead use `x.Equal(y)` where possible Fixes open-policy-agent#8158 Signed-off-by: Anders Eknert <[email protected]> (cherry picked from commit 3300dfc) Signed-off-by: Sebastian Spaink <[email protected]> # Conflicts: # v1/ast/term_test.go
Also:
(*TemplateString).Equal()because why not.x.Compare(y) == 0to instead usex.Equal(y)where possibleFixes #8158