Skip to content

Commit f254613

Browse files
vtjnashtkelman
authored andcommitted
workspace command: fix for missing incremental support (#21714)
* workspace command: fix for missing incremental support * Add a test for #22101 (cherry picked from commit 5c90d2e)
1 parent 39d24bb commit f254613

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/toplevel.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ JL_DLLEXPORT jl_module_t *jl_new_main_module(void)
5454

5555
jl_main_module = jl_new_module(jl_symbol("Main"));
5656
jl_main_module->parent = jl_main_module;
57-
if (old_main) // don't block continued loading of incremental caches
57+
if (old_main) { // don't block continued loading of incremental caches
58+
jl_main_module->primary_world = old_main->primary_world;
5859
jl_main_module->uuid = old_main->uuid;
60+
}
5961
ptls->current_module = jl_main_module;
6062

6163
jl_core_module->parent = jl_main_module;

test/workspace.jl

+34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
using Base.Test
4+
35
script = """
46
# Issue #11948
57
f(x) = x+1
@@ -24,3 +26,35 @@ mutable struct Foo end
2426
@assert Tuple{Type{LastMain.Foo}} !== Tuple{Type{Main.Foo}}
2527
"""
2628
run(`$exename --startup-file=no -e $script2`)
29+
30+
# Issue #22101
31+
mktempdir() do dir
32+
withenv("JULIA_DEBUG_LOADING" => nothing) do
33+
# We need to ensure that the module does a nontrivial amount of work during precompilation
34+
write(joinpath(dir, "Test22101.jl"), """
35+
__precompile__()
36+
module Test22101
37+
export f22101
38+
f22101() = collect(1:10)
39+
f22101()
40+
end
41+
""")
42+
write(joinpath(dir, "testdriver.jl"), """
43+
insert!(LOAD_PATH, 1, $(repr(dir)))
44+
insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir)))
45+
try
46+
using Test22101
47+
f22101()
48+
workspace()
49+
using Test22101
50+
finally
51+
splice!(LOAD_PATH, 1)
52+
splice!(Base.LOAD_CACHE_PATH, 1)
53+
end
54+
exit(isdefined(Main, :f22101) ? 0 : 1)
55+
""")
56+
# Ensure that STDIO doesn't get swallowed (helps with debugging)
57+
cmd = `$(Base.julia_cmd()) --startup-file=no --precompiled=yes --compilecache=yes $(joinpath(dir, "testdriver.jl"))`
58+
@test success(pipeline(cmd, stdout=STDOUT, stderr=STDERR))
59+
end
60+
end

0 commit comments

Comments
 (0)