Violation of PartialEq
, Eq
, PartialOrd
and Ord
contracts in minijinja::Value
#577
Labels
bug
Something isn't working
Description
The
Ord
andPartialEq
implementations ofminijinja::Value
work as follows:Value
s to be equali128
i128
on both sidesThis violates the transitivity property of the comparison traits, which, in addition to producing unexpected but niche behaviour, also can cause panics while sorting due to the new sorting algorithms of Rust 1.81 panicking on invalid
Ord
implementations.Reproduction steps
I wrote a small program that demonstrates the issue
Additional helpful information:
Though none of the above should matter, I think this bug applies to all versions.
What did you expect
Equality and comparison operators should maintain their transitive properties. This is a hard problem with many corner cases. It would involve checking:
This is much more complicated than the existing solution, so it's understandable you went this route, but it does have the issue described above.
Also the above fix only works for
(Partial)Eq
, fixingOrd
is much more complicated.The text was updated successfully, but these errors were encountered: