From a13e6885555917a2e95303ef9222611c203e2b65 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 30 Jun 2022 12:01:59 -0400 Subject: [PATCH] loading: prevent module replacement during precompile This is theoretically okay, but unlikely to be intended ever. (cherry picked from commit d81724aa7be61098ceeb11da64ecdc8921f4f8d5) --- base/loading.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index 5011cb837df3f..97cf10db766d5 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1135,7 +1135,11 @@ root_module_key(m::Module) = @lock require_lock module_keys[m] if haskey(loaded_modules, key) oldm = loaded_modules[key] if oldm !== m - @warn "Replacing module `$(key.name)`" + if (0 != ccall(:jl_generating_output, Cint, ())) && (JLOptions().incremental != 0) + error("Replacing module `$(key.name)`") + else + @warn "Replacing module `$(key.name)`" + end end end loaded_modules[key] = m