Hi all. I’m not sure if this is a bug or if I’m missing something. Essentially, Julia keeps calling the old method after I have redefined it. I have a vague feeling that this may have to do with issue 265 or its fix, and it may well be the intended behavior, but what has me doubt this is that most of the time redefining methods (e.g., using Revise.jl) works just fine. Unfortunately my repro is not very minimal, because only a very specific situation seems to trigger the issue.
The following setup is needed to reproduce the issue:
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.2 (2017-12-13 18:08 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-w64-mingw32
julia> Pkg.clone("https://github.com/s-broda/ARCH.jl")
INFO: Cloning ARCH from https://github.com/s-broda/ARCH.jl
INFO: Computing changes...
INFO: No packages to install, update or remove
julia> Pkg.checkout("ARCH", "repro")
INFO: Checking out ARCH repro...
INFO: Pulling ARCH latest repro...
INFO: No packages to install, update or remove
julia> using ARCH
INFO: Recompiling stale cache file C:\Users\broda\.julia\lib\v0.6\ARCH.ji for module ARCH.
julia> T=10^4; spec = GARCH{1, 1}; coefs = (1., .9, .05); srand(1); data = simulate(spec, T, coefs); ht = zeros(data);
julia> try AM=selectmodel(GARCH, data) end
Now call the problematic method:
julia> ARCH.arch_loglik!(spec, data, ht, [coefs...])
-29182.153014042997
Let’s redefine the method (I’ve actually discovered this using Revise.jl, but it’s not specific to that):
julia> @eval ARCH arch_loglik!{p, q, T1<:FP}(M::Type{GARCH{p,q}}, data::Vector{T1}, ht::Vector{T1}, coefs::Vector{T1}) = 1
WARNING: Method definition arch_loglik!(Type{ARCH.GARCH{p, q}}, Array{T1<:AbstractFloat, 1}, Array{T1<:AbstractFloat, 1}, Array{T1<:AbstractFloat, 1}) in module ARCH at C:\Users\broda\.julia\v0.6\ARCH\src\GARCH.jl:5 overwritten at REPL[7]:1.
arch_loglik! (generic function with 1 method)
And call it:
julia> ARCH.arch_loglik!(spec, data, ht, [coefs...])
-29182.153014042997
So Julia still calls the old method. Even if I do
julia> Base.invokelatest(ARCH.arch_loglik!, spec, data, ht, [coefs...])
-29182.153014042997
Strangely though,
julia> @code_llvm ARCH.arch_loglik!(spec, data, ht, [coefs...])
; Function Attrs: uwtable
define i64 @"julia_arch_loglik!_64535"(i8**, i8** dereferenceable(40), i8** dereferenceable(40), i8** dereferenceable(40)) #0 !dbg !5 {
top:
ret i64 1
}
My versioninfo:
julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17* (2017-12-13 18:08 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-4570S CPU @ 2.90GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Any advice would be appreciated. If this is a bug, then I’m happy to file an issue.
Thanks!
Simon