Stream: helpdesk (published)

Topic: ✔ JET analysis of Base.isless for field Union{T, Nothing}


view this post on Zulip Jakob Nybo Nissen (Aug 15 2023 at 04:52):

The issue is that currently, the Julia compiler doesn't realise that if you load the same field multiple times from the same struct, the field is of the same type. So, even though you checked that a.x is not nothing and b.x is not nothing, when you do the comparison, Julia has "forgotten" that you checked

view this post on Zulip Jakob Nybo Nissen (Aug 15 2023 at 04:53):

You solve it by storing them in a variable

view this post on Zulip Jakob Nybo Nissen (Aug 15 2023 at 04:56):

See more here: https://aviatesk.github.io/JET.jl/stable/jetanalysis/#no-matching-method-found-(x/y-union-split)

view this post on Zulip Jesper Stemann Andersen (Aug 15 2023 at 05:20):

Right! I should’ve re-read the documentation for JET… Thanks!

view this post on Zulip Notification Bot (Aug 15 2023 at 06:09):

Jesper Stemann Andersen has marked this topic as resolved.

view this post on Zulip Sebastian Pfitzner (Aug 15 2023 at 07:11):

worth noting that JET is correct in this specific case -- Bar is mutable after all, so some other thread could write a nothing to a.x or b.x after your check. Only accessing the field once and storing that in a local variable technically changes the behaviour of your program

view this post on Zulip Jesper Stemann Andersen (Aug 15 2023 at 07:16):

Right ... I was also wondering whether that point should be added as a footnote to the JET documentation...


Last updated: Oct 02 2023 at 04:34 UTC