Repository: JuliaPlots/Makie.jl (julia)

Issue:
`contourf!()` gives `StackOverflowError` on `Array{Union{Float64,Missing}}`
- [x] are you running newest version (version from docs) ?
- [??] can you reproduce the bug with a fresh environment ? (`]activate --temp; add Makie`) -- Don't know what to do after `add Makie`
- [x] What platform + GPU are you on? -- macOS 14.2.1, mac mini M2 (early 2023)

Makie v0.20.3

I'm pasting a program that shows the error at the end of this message.  If you replace missing values with `NaN`, a plot is generated as expected.

Is this related to https://github.com/MakieOrg/Makie.jl/issues/1399    ?

```julia
using CairoMakie

b = Array{Union{Float64,Missing}}(rand(Float64, 5, 7))
b[3,3] = missing
b[3,4] = missing

#= #--- works ---
c = replace(b, missing=>NaN)
fig = Figure()
ax = Axis(fig[1,1])
contourf!(ax, axes(c,1), axes(c,2), c) # -> fine
fig
=#

fig = Figure()
ax = Axis(fig[1,1])
contourf!(ax, axes(b,1), axes(b,2), b) # -> fails with "StackOverflowError"
fig
```
The error is
```julia
julia> include("try-makie-missing.jl")
ERROR: LoadError: StackOverflowError:
in expression starting at . . ./try-makie-missing.jl:17
```

Pull request description:
Fixes https://github.com/MakieOrg/Makie.jl/issues/3515

Patch:
diff --git a/src/conversions.jl b/src/conversions.jl
index 4727f2715f5..4f75c9ba3e6 100644
--- a/src/conversions.jl
+++ b/src/conversions.jl
@@ -360,7 +360,7 @@ convert_arguments(ct::VertexGrid, x::AbstractMatrix, y::AbstractMatrix) = conver
 Takes one or two ClosedIntervals `x` and `y` and converts them to closed ranges
 with size(z, 1/2).
 """
-function convert_arguments(P::GridBased, x::RangeLike, y::RangeLike, z::AbstractMatrix)
+function convert_arguments(P::GridBased, x::RangeLike, y::RangeLike, z::AbstractMatrix{<: Union{Number, Colorant}})
     convert_arguments(P, to_linspace(x, size(z, 1)), to_linspace(y, size(z, 2)), z)
 end
 


Test patch:
diff --git a/test/conversions.jl b/test/conversions.jl
index 4d27bf4de6f..be31c61cc7c 100644
--- a/test/conversions.jl
+++ b/test/conversions.jl
@@ -358,6 +358,9 @@ end
         @test convert_arguments(Heatmap, 0:10, v2, m3) == (collect(0f0:10f0), o2, o3)
         @test_throws ErrorException convert_arguments(Heatmap, m1, m2, m3)
         @test_throws ErrorException convert_arguments(Heatmap, m1, m2)
+
+        # https://github.com/MakieOrg/Makie.jl/issues/3515
+        @test convert_arguments(Heatmap, 1:8, 1:8, Array{Union{Float64,Missing}}(zeros(8, 8))) == (0.5:8.5, 0.5:8.5, zeros(8, 8))
     end
 end