julia> x = 1
1
julia> b = x -3 * x^2
-2
julia> x = [1,2,3]
3-element Vector{Int64}:
1
2
3
julia> b = @. x - 3 * x^2
3-element Vector{Int64}:
-2
-10
-24
julia> b = @. x -3 * x^2
ERROR: LoadError: MethodError: no method matching var"@__dot__"(::LineNumberNode, ::Module, ::Symbol, ::Expr)
The function `@__dot__` exists, but no method is defined for this combination of argument types.
Closest candidates are:
var"@__dot__"(::LineNumberNode, ::Module, ::Any)
@ Base broadcast.jl:1303
That seems like a bug. There’s only one method for @., which expects a single expression. There should probably be another method that accepts multiple expressions and concatenates them together. (Macro parsing turns x -3 * x^2 into two expressions, x and -3 * x^2.)
EDIT:
I just looked at the docstring for @.. It’s technically not a bug, because the docstring documents the call as @. expr. In other words, the docstring shows that one expression is expected (though it does not emphasize the fact that only one expression is allowed). However, it might be nice if they could make something like @. x -3 * x^2 work.