Skip to content

Commit bb7a119

Browse files
vtjnashKristofferC
authored andcommitted
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. (cherry picked from commit 9c8886c)
1 parent afa2fcb commit bb7a119

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
@@ -399,10 +399,10 @@ function showerror_ambiguous(io::IO, meths, f, args::Type)
399399
sigfix = typeintersect(m.sig, sigfix)
400400
end
401401
if isa(unwrap_unionall(sigfix), DataType) && sigfix <: Tuple
402-
let sigfix=sigfix
403-
if all(m->morespecific(sigfix, m.sig), meths)
402+
let sigfix=Core.Box(sigfix)
403+
if all(m->morespecific(sigfix.contents, m.sig), meths)
404404
print(io, "\nPossible fix, define\n ")
405-
show_tuple_as_call(io, :function, sigfix)
405+
show_tuple_as_call(io, :function, sigfix.contents)
406406
else
407407
print(io, "To resolve the ambiguity, try making one of the methods more specific, or ")
408408
print(io, "adding a new method more specific than any of the existing applicable methods.")
@@ -487,10 +487,10 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
487487
# If isvarargtype then it checks whether the rest of the input arguments matches
488488
# the varargtype
489489
if Base.isvarargtype(sig[i])
490-
sigstr = (unwrapva(unwrap_unionall(sig[i])), "...")
490+
sigstr = Core.svec(unwrapva(unwrap_unionall(sig[i])), "...")
491491
j = length(t_i)
492492
else
493-
sigstr = (sig[i],)
493+
sigstr = Core.svec(sig[i],)
494494
j = i
495495
end
496496
# Checks if the type of arg 1:i of the input intersects with the current method
@@ -536,9 +536,9 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
536536
for (k, sigtype) in enumerate(sig[length(t_i)+1:end])
537537
sigtype = isvarargtype(sigtype) ? unwrap_unionall(sigtype) : sigtype
538538
if Base.isvarargtype(sigtype)
539-
sigstr = (unwrapva(sigtype::Core.TypeofVararg), "...")
539+
sigstr = Core.svec(unwrapva(sigtype::Core.TypeofVararg), "...")
540540
else
541-
sigstr = (sigtype,)
541+
sigstr = Core.svec(sigtype,)
542542
end
543543
if !((min(length(t_i), length(sig)) == 0) && k==1)
544544
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)