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

World age issues #83

Open
lucianolorenti opened this issue Mar 8, 2020 · 0 comments
Open

World age issues #83

lucianolorenti opened this issue Mar 8, 2020 · 0 comments

Comments

@lucianolorenti
Copy link

lucianolorenti commented Mar 8, 2020

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?

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

No branches or pull requests

1 participant