Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(KernelDSL) MethodError raises uninformative error message #474

Open
femtomc opened this issue Aug 3, 2022 · 3 comments
Open

(KernelDSL) MethodError raises uninformative error message #474

femtomc opened this issue Aug 3, 2022 · 3 comments

Comments

@femtomc
Copy link
Contributor

femtomc commented Aug 3, 2022

WARNING: replacing module GenInferenceTunerTour.
ERROR: LoadError: MethodError: no method matching var"##reverse_kernel#304"(::Gen.DynamicDSLTrace{Gen.DynamicDSLFunction{Any}}, ::Int64, ::Matrix{Float64})┌ Error: Error showing method candidates, aborted
│   exception =
│    could not determine location of method definition
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:33
│      [2] functionloc
│        @ ./methodshow.jl:164 [inlined]
│      [3] show_method_candidates(io::IOContext{Base.TTY}, ex::MethodError, kwargs::Any)
│        @ Base ./errorshow.jl:499
│      [4] showerror(io::IOContext{Base.TTY}, ex::MethodError)
│        @ Base ./errorshow.jl:318
│      [5] showerror(io::IOContext{Base.TTY}, ex::MethodError, bt::Vector{Base.StackTraces.StackFrame}; backtrace::Bool)
│        @ Base ./errorshow.jl:88
│      [6] showerror(io::IOContext{Base.TTY}, ex::LoadError, bt::Vector{Base.StackTraces.StackFrame}; backtrace::Bool)
│        @ Base ./errorshow.jl:96
│      [7] show_exception_stack(io::IOContext{Base.TTY}, stack::Vector{Any})
│        @ Base ./errorshow.jl:866
│      [8] display_error(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
│        @ Base ./client.jl:104
│      [9] #invokelatest#2
│        @ ./essentials.jl:716 [inlined]
│     [10] invokelatest
│        @ ./essentials.jl:714 [inlined]
│     [11] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
│        @ REPL /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/REPL.jl:288
│     [12] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
│        @ REPL /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/REPL.jl:277
│     [13] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
│        @ REPL /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/REPL.jl:510
│     [14] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
│        @ REPL /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/REPL.jl:275
│     [15] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
│        @ REPL /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/REPL.jl:846
│     [16] #invokelatest#2
│        @ ./essentials.jl:716 [inlined]
│     [17] invokelatest
│        @ ./essentials.jl:714 [inlined]
│     [18] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2493
│     [19] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/REPL/src/REPL.jl:1232
│     [20] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL ./task.jl:429
└ @ Base errorshow.jl:320

Stacktrace:
  [1] assess(gen_fn::GenSMCGF.SMCGF{Any, Gen.DynamicDSLTrace, Gen.DynamicDSLFunction{Any}, Nothing, Gen.DynamicDSLFunction{Any}, Nothing, Nothing, typeof(Main.GenInferenceTunerTour.DiscreteHMM.k1), Main.GenInferenceTunerTour.DiscreteHMM.var"###reverse_kernel#304"}, args::Tuple{Vector{Gen.ChoiceMap}, Vector{Tuple{Int64, Main.GenInferenceTunerTour.DiscreteHMM.DiscreteHMMConfiguration}}, Vector{Tuple{Gen.IntDiff, Gen.NoChange}}, Vector{Tuple}, Vector{Tuple}, Int64, Int64}, choices::Gen.DynamicChoiceMap)

Two possibilities:

  1. This is just an uninformative error message for a failure to match method dispatch.
  2. There's an escape/hygiene issue when expanding the kernel DSL into a module, and then calling code from that module.
@femtomc
Copy link
Contributor Author

femtomc commented Aug 3, 2022

This is number (1)

Yikes. I'm keeping this issue open for a future hackathon -- it would be great if we could alleviate this insane stacktrace for method dispatch errors.

@alex-lew
Copy link
Contributor

@femtomc I don't totally follow — is the Kernel DSL still broken in some way? If not, can we rename this issue, and add some description of what problem it's pointing out? (i.e., better error messages in general, or for a specific kind of problem?) Thanks!

@femtomc femtomc changed the title Kernel DSL is still broken (KernelDSL) MethodError raises uninformative error message Aug 21, 2022
@femtomc
Copy link
Contributor Author

femtomc commented Aug 21, 2022

@alex-lew Thanks for keeping track. Yes, it's not broken -- but I found that if a MethodError is thrown, this LoadError is thrown, which doesn't match the "normal" MethodError. I suspect this might be confusing -- and indeed, it confused me when I first saw it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants