From 3946ceed245097aa635eeb8a247c50e40c7d2457 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 31 Dec 2023 07:12:15 -0600 Subject: [PATCH] Correct pc for empty function definition Setting `pc=nothing` is premature at this stage. Together with https://github.com/JuliaDebug/LoweredCodeUtils.jl/pull/91, this fixes #758. --- src/lowered.jl | 2 +- test/runtests.jl | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lowered.jl b/src/lowered.jl index bcf0df71..db536efd 100644 --- a/src/lowered.jl +++ b/src/lowered.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 0e507117..e129eda0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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