diff --git a/implement/Pine.Core/PineValue.cs b/implement/Pine.Core/PineValue.cs index c8fac041..832b5163 100644 --- a/implement/Pine.Core/PineValue.cs +++ b/implement/Pine.Core/PineValue.cs @@ -138,11 +138,30 @@ public virtual bool Equals(ListValue? other) if (other is null) return false; - return ReferenceEquals(this, other) - || - (slimHashCode == other.slimHashCode && - Elements.Count == other.Elements.Count && - Elements.SequenceEqual(other.Elements)); + if (ReferenceEquals(this, other)) + return true; + + if (slimHashCode != other.slimHashCode || Elements.Count != other.Elements.Count) + return false; + + for (int i = 0; i < Elements.Count; i++) + { + var selfElement = Elements[i]; + var otherElement = other.Elements[i]; + + if (selfElement is ListValue selfList && otherElement is ListValue otherList) + { + if (!selfList.Equals(otherList)) + return false; + } + else + { + if (!selfElement.Equals(otherElement)) + return false; + } + } + + return true; } public override int GetHashCode() => slimHashCode;