-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Hello! I am facing a worldage issue when I try to do something like this:
module A
using Requires
function __init__()
@require SQLite="0aa819cd-b072-5ff4-a722-6bc24af294d9" begin
function do_something(d::SQLite.DB)
println(d)
end
end
end
end
module B
using Main.A
using Requires
function connect(cfg::Dict)
if cfg["engine"] == "sqlite"
@eval using SQLite
f = Base.invokelatest(build_sqlite, "a")
A.do_something(f)
end
end
function __init__()
@require SQLite="0aa819cd-b072-5ff4-a722-6bc24af294d9" begin
function build_sqlite(file::String)
return SQLite.DB(file)
end
end
end
end
using Main.B
Main.B.connect(Dict("engine"=>"sqlite"))ERROR: MethodError: no method matching build_sqlite(::String)
The applicable method may be too new: running in world age 26781, while current world is 26792.
In module B, I would like to load SQLite only if a configuration dict says so. But then module A also uses Requires to load all the SQLite related functions when is loaded. And when B tries to call a function from A, the world age issue appears.
I really don't know if I am doing what I want in the correct way. There is a workaround or a different way to do it?
Can I avoid using invokelatest every time I call a function from A?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels