Skip to content

Fix SelfDrop equality#2091

Open
karreiro wants to merge 1 commit into
mainfrom
self-drop-eq
Open

Fix SelfDrop equality#2091
karreiro wants to merge 1 commit into
mainfrom
self-drop-eq

Conversation

@karreiro
Copy link
Copy Markdown
Contributor

@karreiro karreiro commented Jun 2, 2026

Liquid::SelfDrop currently behaves like a wrapper object for equality, even though every meaningful operation delegates back to the captured context. That means two separate self lookups from the same context compare as different values, leaking implementation detail into both Ruby callers and template behavior:

ctx = Liquid::Context.new({})
a = ctx.find_variable("self")
b = ctx.find_variable("self")

[a == b, a.equal?(b), a == a]
# Before: [false, false, true]
# After:  [true,  false, true]

This change makes SelfDrop equality compare the captured context identity, and aligns eql?/hash with the same rule so Ruby hash-key semantics stay coherent.

Copy link
Copy Markdown
Contributor

@aswamy aswamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 I also checked out the test on liquid-spec and seem consistent.

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.

3 participants