This is because of named tuple syntax.
Notice (t1, t2 = (t2, t1))
is short for (t1 = t1, t2 = (t2, t1))
and results in NamedTuple{(:t1, :t2)}((t1, (t2, t1)))
.
So you’ll need to disambiguate a (named) tuple literal from a ()
-grouped expression. You could do this like so:
true && ((t1, t2) = (t2, t1)) # an expression, not a tuple, since no comma
true && begin # explicit block
t1, t2 = t2, t1
end
So this isn’t a bug — just confusion about Julia’s (very carefully designed) syntax!