Fix SelfDrop equality (#2091)

This commit is contained in:
Guilherme Carreiro
2026-06-05 10:47:37 +02:00
committed by GitHub
parent 742ac3dbf5
commit 7b368dffb8
3 changed files with 37 additions and 1 deletions
+1 -1
View File
@@ -208,7 +208,7 @@ module Liquid
# `self` resolves to a SelfDrop (enabling `self['var']` lookups),
# but only when it hasn't been explicitly assigned as a local variable.
return SelfDrop.new(self) if key == Expression::SELF && !index
return @self_drop ||= SelfDrop.new(self) if key == Expression::SELF && !index
variable = if index
lookup_and_evaluate(@scopes[index], key, raise_on_not_found: raise_on_not_found)
+14
View File
@@ -35,6 +35,20 @@ module Liquid
self
end
def ==(other)
other.is_a?(SelfDrop) && other.self_context.equal?(@self_context)
end
alias_method :eql?, :==
def hash
@self_context.object_id.hash
end
protected
attr_reader :self_context
undef context=
end
end