Skip to content

Commit

Permalink
Fix revising baremodules (#427)
Browse files Browse the repository at this point in the history
* Do not crash with baremodule

* Test with baremodule
  • Loading branch information
tkf authored Feb 17, 2020
1 parent 324b787 commit edc1c97
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lowered.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ end

function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, frame, musteval; define=true, skip_include=true)
mod = moduleof(frame)
modinclude = getfield(mod, :include) # hoist this lookup for performance
# Hoist this lookup for performance. Don't throw even when `mod` is a baremodule:
modinclude = isdefined(mod, :include) ? getfield(mod, :include) : nothing
signatures = [] # temporary for method signature storage
pc = frame.pc
while true
Expand Down
28 changes: 28 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,34 @@ end
pop!(hp.history)
end
end

@testset "baremodule" begin
testdir = newtestdir()
dn = joinpath(testdir, "Baremodule", "src")
mkpath(dn)
open(joinpath(dn, "Baremodule.jl"), "w") do io
println(io, """
baremodule Baremodule
f() = 1
end
""")
end
sleep(mtimedelay)
@eval using Baremodule
sleep(mtimedelay)
@test Baremodule.f() == 1
open(joinpath(dn, "Baremodule.jl"), "w") do io
println(io, """
module Baremodule
f() = 2
end
""")
end
yry()
@test Baremodule.f() == 2
rm_precompile("Baremodule")
pop!(LOAD_PATH)
end
end

@testset "Switching free/dev" begin
Expand Down

0 comments on commit edc1c97

Please sign in to comment.