julia> WARNING: Caught an exception in the keymap:
ERROR: MethodError: no method matching (::OhMyREPL.Prompt.##1#28)(::Base.LineEdit.MIState, ::Base.REPL.LineEditREPL, ::String)
The applicable method may be too new: running in world age 20392, while current world is 20418.
Closest candidates are:
#1(::Any, ::Any, ::Any) at /home/kristoffer/.julia/v0.6/OhMyREPL/src/repl.jl:72 (method too new to be called from this world context.)
The error occurs as soon as the package is loaded and a key is pressed.
What the function is supposed to do is to change some hotkeys the REPL normally use to call a few other functions. IIUC this error happens when a method defined in a running context is tried to be called in that context? The method that is said to be too new (at OhMyREPL/src/repl.jl:72) is an anonymous function that gets bound to a key,
D["*"] = (s, data, c) -> (LineEdit.edit_insert(s, c); rewrite_with_ANSI(s))
How should I rewrite this function as to not run into the current problems?
The error means that you are calling a method that’s too new. See here for the doc. The error message shows you that it’s the module specific eval that’s too new and since these are automatically defined when the module is created it’s likely caused by creating modules dynamically and trying to call methods (eval) defined in it. This seems to be what you are doing.
The easiest workaround is to use eval(mod, expr) instead of mod.eval(expr). Also note that instead of using try-catch and eval of a single simple with a no-op interpolation you can just do
if isdefined(parent_module, mod_sym)
jl_mod = getfield(parent_module, mod_sym)
else
jl_mod = Core.eval(parent_module, :(module $mod_sym end))
end
Thanks a lot, working fine now! An additional complication was that the eval at the reported line wasn’t actually the problem, it was later use of eval (in the new module) that triggered it. Replacing all other occurrences with Core.eval fixed it though.