Precompilation Error
Closed this issue · 2 comments
Hi! Just recently got the following error while trying to precompile SpeedyWeather.jl:
Precompiling project...
? SpeedyWeather
1 dependency successfully precompiled in 32 seconds. 309 already precompiled.
1 dependency failed but may be precompilable after restarting julia
1 dependency had output during precompilation:
┌ SpeedyWeather
│ WARNING: Method definition (::Type{SpeedyWeather.Earth{NF} where NF<:AbstractFloat})() in module SpeedyWeather at /n/home07/nwong/.julia/packages/SpeedyWeather/GINRL/src/dynamics/planet.jl:15 overwritten at /n/home07/nwong/.julia/packages/SpeedyWeather/GINRL/src/dynamics/planet.jl:45.
│ ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
└
Yes, I saw that too. The situation is
Base.@kwdef struct S{T}
a::T = 1.2
end
now the method S()
would infer T
from the 1.2::Float64
and therefore decide that if no arguments are provided that would suggest that T
should be something else then use Float64. However, I'd rather use a DEFAULT_NF
constant to define what the default number format should be hence we have
S(;kwargs...) = S{DEFAULT_NF}(;kwargs...)
to always create it with DEFAULT_NF
if only some arguments are provided. That also overwrites the S()
methods above. So I guess we should actually define S
as
Base.@kwdef struct S{T}
a::T = convert(DEFAULT_NF, 1.2)
end
So that S(;kwargs...)
doesn't have to be defined additionally. However, now S(2)
would actually make it S{Int}(2)
... it's tricky!
Maybe we should just remove the
Earth(;kwargs...) = Earth{DEFAULT_NF}(;kwargs...)
method. For a quick Earth()
call the number format doesn't matter and users are advised to always pass on the spectral grid as first argument anyway in which case the number format would be as chosen.