Skip to content

Commit 9c8886c

Browse files
authored
improve compile-ability of method errors (#59709)
This was correct prior to changing closures to use Core.Typeof, but was not corrected when that PR was merged. This doesn't seem to quite fix issue #56861, since we used to have a precompile workload for this, and now REPL is a separate package.
1 parent ffad80c commit 9c8886c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

base/errorshow.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function showerror(io::IO, ex::MethodError)
259259
is_arg_types = !isa(ex.args, Tuple)
260260
arg_types = is_arg_types ? ex.args : typesof(ex.args...)
261261
arg_types_param::SimpleVector = (unwrap_unionall(arg_types)::DataType).parameters
262-
san_arg_types_param = Any[rewrap_unionall(a, arg_types) for a in arg_types_param]
262+
san_arg_types_param = Any[rewrap_unionall(arg_types_param[i], arg_types) for i in 1:length(arg_types_param)]
263263
f = ex.f
264264
meth = methods_including_ambiguous(f, arg_types)
265265
if isa(meth, MethodList) && length(meth) > 1
@@ -423,10 +423,10 @@ function showerror_ambiguous(io::IO, meths, f, args::Type)
423423
sigfix = typeintersect(m.sig, sigfix)
424424
end
425425
if isa(unwrap_unionall(sigfix), DataType) && sigfix <: Tuple
426-
let sigfix=sigfix
427-
if all(m->morespecific(sigfix, m.sig), meths)
426+
let sigfix=Core.Box(sigfix)
427+
if all(m->morespecific(sigfix.contents, m.sig), meths)
428428
print(io, "\nPossible fix, define\n ")
429-
show_tuple_as_call(io, :function, sigfix)
429+
show_tuple_as_call(io, :function, sigfix.contents)
430430
else
431431
print(io, "To resolve the ambiguity, try making one of the methods more specific, or ")
432432
print(io, "adding a new method more specific than any of the existing applicable methods.")
@@ -511,10 +511,10 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
511511
# If isvarargtype then it checks whether the rest of the input arguments matches
512512
# the varargtype
513513
if Base.isvarargtype(sig[i])
514-
sigstr = (unwrapva(unwrap_unionall(sig[i])), "...")
514+
sigstr = Core.svec(unwrapva(unwrap_unionall(sig[i])), "...")
515515
j = length(t_i)
516516
else
517-
sigstr = (sig[i],)
517+
sigstr = Core.svec(sig[i],)
518518
j = i
519519
end
520520
# Checks if the type of arg 1:i of the input intersects with the current method
@@ -560,9 +560,9 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
560560
for (k, sigtype) in enumerate(sig[length(t_i)+1:end])
561561
sigtype = isvarargtype(sigtype) ? unwrap_unionall(sigtype) : sigtype
562562
if Base.isvarargtype(sigtype)
563-
sigstr = (unwrapva(sigtype::Core.TypeofVararg), "...")
563+
sigstr = Core.svec(unwrapva(sigtype::Core.TypeofVararg), "...")
564564
else
565-
sigstr = (sigtype,)
565+
sigstr = Core.svec(sigtype,)
566566
end
567567
if !((min(length(t_i), length(sig)) == 0) && k==1)
568568
print(iob, ", ")

base/experimental.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ the handler for that type.
315315
This interface is experimental and subject to change or removal without notice.
316316
"""
317317
function show_error_hints(io, ex, args...)
318+
@nospecialize
318319
hinters = get(_hint_handlers, typeof(ex), nothing)
319320
isnothing(hinters) && return
320321
for handler in hinters

0 commit comments

Comments
 (0)