You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstract type VolatilitySpec end
struct GARCH{p,q} <: VolatilitySpec end
struct ARCHModel{VS<:VolatilitySpec}
ARCHModel{VS}() where {VS}=new()
end
ARCHModel(VS::Type{T}) where {T<:VolatilitySpec} = ARCHModel{VS}()
loglikelihood(am::ARCHModel{T}) where{T} = arch_loglik!(T)
function arch_loglik!(M::Type{GARCH{p,q}}) where {p, q}
return 5.
end
function selectmodel()
res = Array{ARCHModel, 2}(4, 4)
for p = 0:3, q = 0:3
res[p+1, q+1] = ARCHModel(GARCH{p, q})
end
crits = loglikelihood.(res)
end
Calling the method works as expected:
julia> arch_loglik!(GARCH{1, 1})
5.0
Now, call the function selectmodel (this step is crucial for reproducing the issue) and redefine the method (note no warning about the method redefinition):
julia> selectmodel();
julia> arch_loglik!{p, q}(M::Type{GARCH{p,q}}) = 1
arch_loglik! (generic function with 1 method)
However, the new definition doesn't take effect, despite @code_llvm showing the updated definition:
there is a redefinition warning if the above is enclosed in a module other than Main.
invokelatest seems to call the expected method in 0.7 but not 0.6.2.
failure to get the updated method seems to depend on details of how the original was used in the selectmodel function: broadcast (as shown above), map, and certain loop expressions (even without hidden closures, AFAICT) show the problem, but scalar calls and some other loops do not.
the method tables seem to show sensible values for world age on the two versions.
My code is not compatible with 0.7 yet, so I can't test the original issue. I can confirm however that the MWE above is fixed on latest Windows nightly. Feel free to close.
Reduced from here https://discourse.julialang.org/t/julia-calls-the-old-method-after-method-is-redefined/10327/7:
Setup:
Calling the method works as expected:
Now, call the function
selectmodel
(this step is crucial for reproducing the issue) and redefine the method (note no warning about the method redefinition):However, the new definition doesn't take effect, despite
@code_llvm
showing the updated definition:The text was updated successfully, but these errors were encountered: