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
You solve it by storing them in a variable
See more here: https://aviatesk.github.io/JET.jl/stable/jetanalysis/#no-matching-method-found-(x/y-union-split)
Right! I should’ve re-read the documentation for JET… Thanks!
Jesper Stemann Andersen has marked this topic as resolved.
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
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