Skip to content

Commit

Permalink
fix incremental requires
Browse files Browse the repository at this point in the history
prevent read_verify_mod_list from adding a binding to Main
  • Loading branch information
vtjnash committed Oct 26, 2016
1 parent b7634be commit 0032592
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,9 @@ static jl_value_t *read_verify_mod_list(ios_t *s)
name[len] = '\0';
uint64_t uuid = read_uint64(s);
jl_sym_t *sym = jl_symbol(name);
jl_module_t *m = (jl_module_t*)jl_get_global(jl_main_module, sym);
jl_module_t *m = NULL;
if (jl_binding_resolved_p(jl_main_module, sym))
m = (jl_module_t*)jl_get_global(jl_main_module, sym);
if (!m) {
static jl_value_t *require_func = NULL;
if (!require_func)
Expand Down
26 changes: 22 additions & 4 deletions test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ function redirected_stderr(expected)
return t
end

Foo_module = :Foo4b3a94a1a081a8cb
FooBase_module = :FooBase4b3a94a1a081a8cb
@eval module ConflictingBindings
export $Foo_module, $FooBase_module
$Foo_module = 232
$FooBase_module = 9134
end
using ConflictingBindings

# this environment variable would affect some error messages being tested below
# so we disable it for the tests below
withenv( "JULIA_DEBUG_LOADING" => nothing ) do
Expand All @@ -25,15 +34,24 @@ dir = mktempdir()
dir2 = mktempdir()
insert!(LOAD_PATH, 1, dir)
insert!(Base.LOAD_CACHE_PATH, 1, dir)
Foo_module = :Foo4b3a94a1a081a8cb
try
Foo_file = joinpath(dir, "$Foo_module.jl")
FooBase_file = joinpath(dir, "$FooBase_module.jl")

write(FooBase_file,
"""
__precompile__(true)
module $FooBase_module
end
""")
write(Foo_file,
"""
__precompile__(true)
module $Foo_module
using $FooBase_module
# test that docs get reconnected
@doc "foo function" foo(x) = x + 1
include_dependency("foo.jl")
Expand Down Expand Up @@ -127,7 +145,7 @@ try
end
wait(t)

let Foo = eval(Main, Foo_module)
let Foo = getfield(Main, Foo_module)
@test Foo.foo(17) == 18
@test Foo.Bar.bar(17) == 19

Expand All @@ -140,8 +158,8 @@ try
@test map(x -> x[1], sort(deps)) == [Foo_file, joinpath(dir, "bar.jl"), joinpath(dir, "foo.jl")]

modules, deps1 = Base.cache_dependencies(cachefile)
@test sort(modules) == map(s -> (s, Base.module_uuid(eval(s))),
[:Base, :Core, :Main])
@test sort(modules) == Any[(s, Base.module_uuid(getfield(Foo, s))) for s in
[:Base, :Core, FooBase_module, :Main]]
@test deps == deps1

@test current_task()(0x01, 0x4000, 0x30031234) == 2
Expand Down

0 comments on commit 0032592

Please sign in to comment.