MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.37k stars 302 forks source link

Recipe StackOverflowError with `[]` as function argument #4033

Closed mauro3 closed 1 week ago

mauro3 commented 1 month ago

Consider this recipe just wrapping a lines plot

using GLMakie
@recipe(PltLine, x, y, z) do scene
    Attributes()
end
function Makie.plot!(plot::PltLine)
    lines!(plot, plot.x, plot.y)
end
pltline(1:3, 1:3, [])

produces

ERROR: LoadError: StackOverflowError:
Stacktrace:
  [1] Array
    @ ./boot.jl:477 [inlined]
  [2] Array
    @ ./boot.jl:486 [inlined]
....

whereas pltline(1:3, 1:3, nothing) works as well as pltline(1:3,1:3, Int[]). This confused me quite a bit. Note that the error which lines(1:3, []) produces is better, namely MethodError: reducing over an empty collection is not allowed.

mauro3 commented 1 month ago

Related #3567

ffreyer commented 1 week ago

Seems to be fixed