Error by `append(a::Vector{T}, b::Vector{T})::Vector{T} where T = vcat(a, b)`

I think it has to do with how the function is parsed.

ex1 = Meta.parse("append(a::Vector{T}, b::Vector{T})::Vector{T} where T = vcat(a, b)")


julia> ex1.args[1].head

:(::)

julia> ex1.args[1].args

2-element Vector{Any}:

:(append(a::Vector{T}, b::Vector{T}))

:(Vector{T} where T)

Adding parenthesis solves your problem:

(append(a::Vector{T}, b::Vector{T})::Vector{T}) where T = vcat(a, b)

ex2 = Meta.parse("(append(a::Vector{T}, b::Vector{T})::Vector{T}) where T = vcat(a, b)")


julia> ex2.args[1].head

:where

julia> ex2.args[1].args

2-element Vector{Any}:

:(append(a::Vector{T}, b::Vector{T})::Vector{T})

:T

2 Likes