RecipesBase.jl
RecipesBase.jl copied to clipboard
`@userplot` struct and function name can clash
The struct name declared for a @userplot
is not constrained AFAIK, so it can clash with the function name that is generated as a result.
MWE:
julia> using RecipesBase
julia> @userplot myplot
myplot! (generic function with 2 methods)
julia> myplot(1:3)
myplot(1:3)
This is a problem in practice when the @recipe
can take just one positional argument, e.g.
julia> @recipe function f(plot::myplot)
x = plot.args[1]
@series begin
x, 2x
end
end
julia> myplot(1:3)
myplot(1:3) # returns struct instead of Plot
The docs implicitly suggest using camel case for the struct name, but a user shouldn't have to know how the macro works to avoid this issue - detecting the problem and throwing an error would be more helpful.