Skip to content

Conversation

@anderseknert
Copy link
Member

@anderseknert anderseknert commented Dec 25, 2025

Also:

  • Add (*TemplateString).Equal() because why not.
  • Update x.Compare(y) == 0 to instead use x.Equal(y) where possible

Fixes #8158

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]>
@netlify
Copy link

netlify bot commented Dec 25, 2025

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 31cf47a
🔍 Latest deploy log https://app.netlify.com/projects/openpolicyagent/deploys/694d193894af8a0008084c78
😎 Deploy Preview https://deploy-preview-8159--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@srenatus srenatus left a 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..
Copy link
Contributor

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?

Copy link
Member Author

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 🙂

@anderseknert anderseknert merged commit 3300dfc into open-policy-agent:main Dec 25, 2025
31 checks passed
@anderseknert anderseknert deleted the ts-term-copy branch December 25, 2025 21:40
@anderseknert anderseknert mentioned this pull request Jan 6, 2026
sspaink pushed a commit to sspaink/opa that referenced this pull request Jan 6, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Copy() implementation for template strings has compiler overwrite parsed module

2 participants