Stream: helpdesk (published)

Topic: Hard to debug constructor error


view this post on Zulip Michael Fiano (Aug 09 2022 at 22:02):

I've seen this quite a few times, and it is very hard to figure out what the compiler is trying to tell me. I have no idea why the name is gensymed, when methods shows me exactly what I supplied. There are no other constructor methods for this type, just this one:

struct Cellular{N} <: AbstractSampler{N}
    random_state::RandomState
    table::Vector{Float64}
    jitter::Float64
    metric::DistanceMetric
    cell_func::CellFunction
    function Cellular{N}(;
        seed::Seed=nothing,
        jitter::Real=1.0,
        metric::DistanceMetric=Euclidean,
        cell_func::CellFunction=F1,
    ) where {N}
        rs = RandomState(seed)
        table = rand(rs.rng, Uniform(-1.0, 1.0), table_size(Val(N)))
        new{N}(rs, table, jitter, metric, cell_func)
    end
end
(CoherentNoise) julia> s = Cellular{2}(seed=1)
ERROR: MethodError: no method matching (::CoherentNoise.Noise.CellularNoise.var"#_#1#2")(::Int64, ::Float64, :
:Type{Euclidean}, ::Type{F1}, ::Type{Cellular{2}})
Closest candidates are:
  (::CoherentNoise.Noise.CellularNoise.var"#_#1#2")(::Union{Nothing, Integer}, ::Real, ::CoherentNoise.Noise.C
ellularNoise.DistanceMetric, ::CoherentNoise.Noise.CellularNoise.CellFunction, ::Type{Cellular{N}}) where N at
 ~/projects/Julia/CoherentNoise/src/noise_cellular.jl:32
Stacktrace:
 [1] top-level scope
   @ REPL[5]:1

Last updated: Oct 02 2023 at 04:34 UTC