There is a critical issue with IArray
’s equality behavior that significantly impacts its usability, particularly within case classes. The default reference equality, even for single-dimensional arrays, violates core immutability principles and breaches the expected promise of value-based equality in Scala.
When IArray
is used as a field in a case class, the automatically generated equals
method compares references instead of content, leading to unexpected inequality for case class instances with identical IArray
values. This directly contradicts the expected behavior of case classes and immutable data structures.
Workarounds, such as encapsulating the IArray
instance in a custom wrapper class for consistent equality, introduce significant overhead, negating the performance benefits of IArray
. This effectively renders IArray
less useful, especially when compared to controlled mutable array encapsulation, which could be more efficient in certain scenarios.
Therefore, i urgently request improvements to IArray
’s equality, ideally through value-based equality by default or a robust mechanism for customizable equality checks. This is essential to ensure IArray
fulfills its intended purpose as a reliable, predictable, and efficient immutable data structure in Scala 3, and to restore consistency with case class equality expectations.