JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.42k stars 191 forks source link

Avoid name clashes in `PrecompileStagingArea` #837

Closed Drvi closed 1 year ago

Drvi commented 1 year ago

On 1.10 we were running into cannot declare anonymous.<OurModule> constant; it already has a value issues as the extra_precompiles statement could import a module whose name clashes with an identifier that is already present in the PrecompileStagingArea, a la:

julia> import Dates

julia> mod = Module()
Main.anonymous

julia> @eval mod Dates = $Dates
Dates

julia> @eval mod import Dates
ERROR: cannot declare anonymous.Dates constant; it already has a value
Stacktrace:
 [1] eval(m::Module, e::Any)
   @ Core ./boot.jl:383
 [2] top-level scope
   @ REPL[345]:1

The issue is present e.g. in ubuntu nightly CI:

...
LoadError: cannot declare anonymous.MyApp constant; it already has a value
...
codecov[bot] commented 1 year ago

Codecov Report

Merging #837 (5e64d0b) into master (7f0607c) will increase coverage by 0.04%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #837      +/-   ##
==========================================
+ Coverage   84.03%   84.07%   +0.04%     
==========================================
  Files           3        3              
  Lines         714      716       +2     
==========================================
+ Hits          600      602       +2     
  Misses        114      114              
Files Changed Coverage Δ
src/PackageCompiler.jl 93.55% <100.00%> (+0.01%) :arrow_up:

... and 1 file with indirect coverage changes