This is valid code:
julia> x,y = 1,2
(1, 2)
julia> x
1
julia> y
2
But, the quoted expression isn’t correct and cannot be evaluated…
julia> :(x,y = 1,2) |> dump
Expr
head: Symbol tuple
args: Array{Any}((3,))
1: Symbol x
2: Expr
head: Symbol =
args: Array{Any}((2,))
1: Symbol y
2: Int64 1
3: Int64 2
julia> :(x,y = 1,2) |> eval
ERROR: syntax: invalid named tuple element "x"
Looks like it’s parsing it as a 3-tuple of x
, y=1
, and 2
instead. Obviously, that won’t work.
If I wrap everything in parentheses then it is fine.
julia> :((x,y) = (1,2)) |> dump
Expr
head: Symbol =
args: Array{Any}((2,))
1: Expr
head: Symbol tuple
args: Array{Any}((2,))
1: Symbol x
2: Symbol y
2: Expr
head: Symbol tuple
args: Array{Any}((2,))
1: Int64 1
2: Int64 2
julia> :((x,y) = (1,2)) |> eval
(1, 2)
Is this a parsing bug?