I think I’ve found a bug with the @.
macro
julia> function foo(;x = 0, y = 8)
return x
end
foo (generic function with 1 method)
julia> a = [1, 2, 3]; b = [4, 5, 6];
julia> foo(; x = @. a * b, y = b)
ERROR: DimensionMismatch("array could not be broadcast to match destination")
I think @.
is being too “greedy”, for lack of a better word. It’s not respecting the fact that it’s scope ends at the ,
. For instance
julia> foo(; x = @. a * b,)
ERROR: syntax: unexpected ")"
But
julia> foo(;x = @. a & b)
3-element Array{Int64,1}:
0
0
2
Sorry for focusing on keyword arguments, here is another example with positional arguments.
julia> bar(x, y) = x
bar (generic function with 1 method)
julia> bar(@. a * b, b)
ERROR: MethodError: no method matching bar(::Tuple{Array{Int64,1},Array{Int64,1}})