Skip to content

Commit a9d8c85

Browse files
fix error show edge case (#44319)
* fix errors Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
1 parent dbb0e50 commit a9d8c85

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

base/errorshow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
508508
end
509509
print(iob, ")")
510510
show_method_params(iob0, tv)
511-
file, line = functionloc(method)
511+
file, line = updated_methodloc(method)
512512
if file === nothing
513513
file = string(method.file)
514514
end

test/error.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,13 @@ end
8686
e = SystemError("fail")
8787
@test e.extrainfo === nothing
8888
end
89+
90+
@testset "MethodError for methods without line numbers" begin
91+
try
92+
eval(Expr(:function, :(f44319()), 0))
93+
f44319(1)
94+
catch e
95+
s = sprint(showerror, e)
96+
@test s == "MethodError: no method matching f44319(::Int64)\nClosest candidates are:\n f44319() at none:0"
97+
end
98+
end

0 commit comments

Comments
 (0)