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

force a require if binding with different uuid is present. #21537

Closed
wants to merge 3 commits into from

Conversation

vchuravy
Copy link
Sponsor Member

This works around Base.Iterators shadowing Iterators, as noted in #21492.

I don't quite understand why that didn't happen before #21492, but that fixes it for me locally.
@fredrikekre and @bjarthur could you try this locally?

This works around `Base.Iterators` shadowing `Iterators`,
as noted in #21492.
@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 24, 2017

This is going to cause warnings and break inference:

julia> Iterators
Base.Iterators

julia> using Iterators
WARNING: imported binding for Iterators overwritten in module Main

`isdefined` will immediatly resolve the binding. Since we are only
trying to skip the path lookup the weaker version `isbindingresolved`
is enough. `isbindingresolved` is also used for this purpose in
`read_verify_mod_list` in `src/dump.c`.
@vchuravy
Copy link
Sponsor Member Author

Thanks! Now it also makes sense why #21492 would trigger this. I think we should drop the first commit here?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 25, 2017

I think that first commit is actually somewhat more consistent:

julia> Iterators
Base.Iterators

julia> using Iterators
WARNING: imported binding for Iterators overwritten in module Main

Although we should only trigger that if using would have triggered it, e.g. not in the case of:

julia> module Iterators end

@vchuravy
Copy link
Sponsor Member Author

I am not sure I understand the last part of your comment. Do you mean that this:

julia> module Iterators end
Iterators

julia> using Compose
WARNING: replacing module Iterators.

Should fail instead of replacing the module? How do I best differentiate between a latent binding and real one?

@vchuravy
Copy link
Sponsor Member Author

There is of course the option of doing the uuid check in stale_cachefile, so that in that case we invalidate the cachefile since a module is present that conflicts with the needed state of the world.

@TotalVerb
Copy link
Contributor

TotalVerb commented Apr 25, 2017

The only long term solution to this is to not use the same module for the REPL and the package root, but that can't be done for 0.6. In the interim, REPL work should avoid using or defining things named Iterators (or, for that matter, anything that coincides with the name of a package which might be imported into Main later).

@vchuravy
Copy link
Sponsor Member Author

With the newest commit (after precompiling compose)

julia> module Iterators end
Iterators

julia> using Compose
INFO: Recompiling stale cache file /home/wallnuss/.julia/lib/v0.6/Compose.ji for module Compose.
WARNING: Module Iterators with uuid 17790850044939 is missing from the cache.
This may mean module Iterators does not support precompilation but is imported by a module that does.
ERROR: LoadError: Declaring __precompile__(false) is not allowed in files that are being precompiled.
Stacktrace:
 [1] require(::Symbol) at ./loading.jl:423
 [2] include_from_node1(::String) at ./loading.jl:539
 [3] include(::String) at ./sysimg.jl:14
 [4] anonymous at ./<missing>:2
while loading /home/wallnuss/.julia/v0.6/Compose/src/Compose.jl, in expression starting on line 6
ERROR: Failed to precompile Compose to /home/wallnuss/.julia/lib/v0.6/Compose.ji.
Stacktrace:
 [1] compilecache(::String) at ./loading.jl:673
 [2] require(::Symbol) at ./loading.jl:431

which is in my opinion the right error for this situation.

@vchuravy vchuravy added backport pending 0.5 needs tests Unit tests are required for this change labels Apr 25, 2017
@vchuravy
Copy link
Sponsor Member Author

There is another edge-case that I will take a look at later:

julia> using Compose
ERROR: ArgumentError: Module Base not found in current path.
Run `Pkg.add("Base")` to install the Base package.
Stacktrace:
 [1] require(::Symbol) at ./loading.jl:403
 [2] _include_from_serialized(::String) at ./loading.jl:157
 [3] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:194
 [4] _require_search_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:224
 [5] require(::Symbol) at ./loading.jl:409
 [6] _include_from_serialized(::String) at ./loading.jl:157
 [7] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:194
 [8] _require_search_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:224
 [9] require(::Symbol) at ./loading.jl:409
 [10] _include_from_serialized(::String) at ./loading.jl:157
 [11] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:194
 [12] _require_search_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:224
 [13] require(::Symbol) at ./loading.jl:409

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 25, 2017

I think that last one is from falling through when finding that the Base module is incompatible (trying to replace it), rather than returning a failure.

Should fail instead of replacing the module? How do I best differentiate between a latent binding and real one?

The primary goal is to replicate the logic of using so that the cache-loading behavior is (mostly) independent of whether it goes through the runtime require function, or the cache load:

julia> Iterators
Base.Iterators

julia> module Test
         using Iterators
       end
WARNING: imported binding for Iterators overwritten in module Main
Test

(sadly though, in this example case, it's also still broken and unable to actually use Iterators, but that's a different bug)

julia> Test.Iterators
WARNING: both Iterators and Base export "Iterators"; uses of it in module Test must be qualified
ERROR: UndefVarError: Iterators not defined

@vchuravy
Copy link
Sponsor Member Author

Ok I split out 2a61131 into a seperate PR since everything in here can wait and needs more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs tests Unit tests are required for this change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants