Skip to content

Commit

Permalink
Correct pc for empty function definition (#785)
Browse files Browse the repository at this point in the history
Setting `pc=nothing` is premature at this stage.
Together with JuliaDebug/LoweredCodeUtils.jl#91,
this fixes #758.
  • Loading branch information
timholy authored Dec 31, 2023
1 parent 4803987 commit 76e8c48
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lowered.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, fra
add_signature!(methodinfo, sig, lnn)
end
end
pc = ret
pc += 1
else
pc, pc3 = ret
# Get the line number from the body
Expand Down
26 changes: 26 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,32 @@ const issue639report = []
rm_precompile("A339")
rm_precompile("B339")

# Combining `include` with empty functions (issue #758)
write(joinpath(testdir, "Issue758.jl"), """
module Issue758
global gvar = true
function f end
include("Issue758helperfile.jl")
end
""")
write(joinpath(testdir, "Issue758helperfile.jl"), "")
sleep(mtimedelay)
using Issue758
sleep(mtimedelay)
@test_throws MethodError Issue758.f()
sleep(mtimedelay)
write(joinpath(testdir, "Issue758.jl"), """
module Issue758
global gvar = true
function f end
f() = 1
include("Issue758helperfile.jl")
end
""")
yry()
@test Issue758.f() == 1
rm_precompile("Issue758")

pop!(LOAD_PATH)
end

Expand Down

0 comments on commit 76e8c48

Please sign in to comment.