Tested on Julia 1.7.2:
julia> t1 = rand(4)
4-element Vector{Float64}:
0.8846483727403565
0.5933843798087087
0.23231684762850824
0.6599451690863327
julia> t2 = rand(5)
5-element Vector{Float64}:
0.9708033624024174
0.9204864722716941
0.07792097172573631
0.43291967469455217
0.7960005316340157
julia> t1, t2 = t2, t1
([0.9708033624024174, 0.9204864722716941, 0.07792097172573631, 0.43291967469455217, 0.7960005316340157], [0.8846483727403565, 0.5933843798087087, 0.23231684762850824, 0.6599451690863327])
julia> t1
5-element Vector{Float64}:
0.9708033624024174
0.9204864722716941
0.07792097172573631
0.43291967469455217
0.7960005316340157
julia> t2
4-element Vector{Float64}:
0.8846483727403565
0.5933843798087087
0.23231684762850824
0.6599451690863327
julia> true && (t1, t2 = (t2, t1))
(t1 = [0.9708033624024174, 0.9204864722716941, 0.07792097172573631, 0.43291967469455217, 0.7960005316340157], t2 = ([0.8846483727403565, 0.5933843798087087, 0.23231684762850824, 0.6599451690863327], [0.9708033624024174, 0.9204864722716941, 0.07792097172573631, 0.43291967469455217, 0.7960005316340157]))
julia> t1
5-element Vector{Float64}:
0.9708033624024174
0.9204864722716941
0.07792097172573631
0.43291967469455217
0.7960005316340157
julia> t2
4-element Vector{Float64}:
0.8846483727403565
0.5933843798087087
0.23231684762850824
0.6599451690863327
julia> true && ((t1, t2) = (t2, t1))
([0.8846483727403565, 0.5933843798087087, 0.23231684762850824, 0.6599451690863327], [0.9708033624024174, 0.9204864722716941, 0.07792097172573631, 0.43291967469455217, 0.7960005316340157])
julia> t1
4-element Vector{Float64}:
0.8846483727403565
0.5933843798087087
0.23231684762850824
0.6599451690863327
julia> t2
5-element Vector{Float64}:
0.9708033624024174
0.9204864722716941
0.07792097172573631
0.43291967469455217
0.7960005316340157
The values of t1
and t2
are not correctly exchanged when it’s part of the short-circuit evaluation unless I put parentheses on both sides of =
. Moreover, the printed info of true && (t1, t2 = (t2, t1))
does not even match the output values. In the printed info, it’s suggested that the operation is
julia> true && (t1; t2 = (t2, t1))
([0.9708033624024174, 0.9204864722716941, 0.07792097172573631, 0.43291967469455217, 0.7960005316340157], [0.8846483727403565, 0.5933843798087087, 0.23231684762850824, 0.6599451690863327])
However, in this case the printed info is incorrectly corresponding to true && (t1, t2 = (t2, t1))
.
I think this is a bug? Thank you!