Stream: helpdesk (published)

Topic: TypeVar equivalence


view this post on Zulip Timothy (May 12 2023 at 15:33):

Might anybody be able to explain this?

julia> TypeVar(:T, Union{}, Tuple) == TypeVar(:T, Union{}, Tuple)
false

view this post on Zulip Sukera (May 12 2023 at 15:40):

probably falls back to ===?

view this post on Zulip Timothy (May 12 2023 at 15:41):

Shouldn't this be egal since the struct and all the values are immutable?

view this post on Zulip Sukera (May 12 2023 at 15:42):

I don't know, I haven't actually checked - I'm compiling from source at the moment, give me a sec

view this post on Zulip Timothy (May 12 2023 at 15:42):

No rush :)

view this post on Zulip Sukera (May 12 2023 at 15:42):

this === fallback is usually to "blame" though for == giving false unexpectedly

view this post on Zulip Sukera (May 12 2023 at 15:46):

yup, falls back to ===

view this post on Zulip Sukera (May 12 2023 at 15:47):

The reason they're different is this

julia> TypeVar(:T, Union{}, Tuple) |> objectid
0x9b328216bd30c6e0

julia> TypeVar(:T, Union{}, Tuple) |> objectid
0xb3dca792ef09a1bc

view this post on Zulip Timothy (May 12 2023 at 15:47):

Hmm, I thought egal / === for immutable structs was defined by === on its fields?

view this post on Zulip Sukera (May 12 2023 at 15:48):

they're not considered egal due to that - and my guess for the reasoning behind that is that while both TypeVars describe the same extent, refining them _doesn't_ anymore

view this post on Zulip Sukera (May 12 2023 at 15:48):

also

julia> TypeVar(:T, Union{}, Tuple) |> isimmutable
false

view this post on Zulip Timothy (May 12 2023 at 15:48):

Ah, that's a surprise


Last updated: Oct 02 2023 at 04:34 UTC