Skip to content

Commit

Permalink
fix error show edge case (#44319)
Browse files Browse the repository at this point in the history
* fix errors

Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
  • Loading branch information
oscardssmith and simeonschaub authored Mar 3, 2022
1 parent dbb0e50 commit a9d8c85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
end
print(iob, ")")
show_method_params(iob0, tv)
file, line = functionloc(method)
file, line = updated_methodloc(method)
if file === nothing
file = string(method.file)
end
Expand Down
10 changes: 10 additions & 0 deletions test/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ end
e = SystemError("fail")
@test e.extrainfo === nothing
end

@testset "MethodError for methods without line numbers" begin
try
eval(Expr(:function, :(f44319()), 0))
f44319(1)
catch e
s = sprint(showerror, e)
@test s == "MethodError: no method matching f44319(::Int64)\nClosest candidates are:\n f44319() at none:0"
end
end

0 comments on commit a9d8c85

Please sign in to comment.