You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: I discovered this problem using JSON3 where deserialisation/serialisation identities failed however could reproduce the issue in without those packages loaded. The same holds for uuid1. This is extremely cursed.
Some more testing yielded that:
cornflakes =string(flower(uidv, uid))
@assert cornflakes ==string(flower(uidv, uid)) ## passes
soap = Meta.parse(cornflakes)
@assert soap == Meta.parse(cornflakes) ## passes@asserteval(soap) ==eval(soap) ## Fails## this also fails@asserteval(:(flower(UUID[UUID("c473d632-4815-11ee-047b-53ba6f201cba"), UUID("c473d644-4815-11ee-2bf5-01764c9f2b45"), UUID("c473d658-4815-11ee-361c-3d983a147777")], UUID("c4745718-4815-11ee-1ec9-fb22fba57306")))) ==eval(:(flower(UUID[UUID("c473d632-4815-11ee-047b-53ba6f201cba"), UUID("c473d644-4815-11ee-2bf5-01764c9f2b45"), UUID("c473d658-4815-11ee-361c-3d983a147777")], UUID("c4745718-4815-11ee-1ec9-fb22fba57306"))))
## while those two pass@asserteval(:(UUID[UUID("c473d632-4815-11ee-047b-53ba6f201cba"), UUID("c473d644-4815-11ee-2bf5-01764c9f2b45"), UUID("c473d658-4815-11ee-361c-3d983a147777")])) ==eval(:(UUID[UUID("c473d632-4815-11ee-047b-53ba6f201cba"), UUID("c473d644-4815-11ee-2bf5-01764c9f2b45"), UUID("c473d658-4815-11ee-361c-3d983a147777")]))
@asserteval(:(UUID("c473d658-4815-11ee-361c-3d983a147777"))) ==eval(:(UUID("c473d658-4815-11ee-361c-3d983a147777")))
The text was updated successfully, but these errors were encountered:
I don't see the issue. There are two different arrays (in the car field), and they are not ===, so they are distinctly different flower structs with different == and hash. That seems to be what you are seeing too, as I would expect
This happens because == is not explicitly defined for Foo, so it falls back to the following fallback definition
==(x, y) = x === y
And since the two inner arrays are not === to each other, the result is false.
The === fallback is unfortunate. Issues #4648 and #40717 propose alternative (and IMO, better) solutions, but changing the default fallback is breaking, so it will probably never happen.
freemin7
changed the title
struct of UUIDs fails comparisons to itself
Comparisons of structs with == lower suprisingly to === and documenation doesn't make it clear
Aug 31, 2023
And the documentation while truthful is only truthful by omission. When i work with UUIDs and serialization i think "someone might have messed up the interning" https://en.wikipedia.org/wiki/Interning_(computer_science) of UUIDs and while i read "Falls back to ===." in ?== that wasn't strong enough language to consider that it a sensible default wasn't chosen for structs. The "For example," makes the listing of exception to the fallback incomplete. "structs being a direct sub-type of Any use the fallback by default." would have been sufficiently explicit to grab my attention.
Another alternative would be a referencing a struct_equal #4648 (comment) in a see also section if something like that existed in stdlib. Does something like that exist in Base already?
Either way the issue could be closed by a more explicit documentation.
installed via JuliaUp
Context: I discovered this problem using JSON3 where deserialisation/serialisation identities failed however could reproduce the issue in without those packages loaded. The same holds for
uuid1
. This is extremely cursed.Some more testing yielded that:
The text was updated successfully, but these errors were encountered: