Skip to content

Commit d738580

Browse files
vtjnashmbauman
authored andcommitted
fix some bitrot in inline_incompletematch (from JuliaLang#7075) now that JuliaLang#10380 is merged and it works & can be tested
1 parent e071b3b commit d738580

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

base/inference.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -2319,8 +2319,9 @@ function inlineable(f::ANY, e::Expr, atype::ANY, sv::StaticVarInfo, enclosing_as
23192319
push!(newcall.args, argtype===Any ? name : SymbolNode(name, argtype))
23202320
end
23212321
body.args = Any[Expr(:return, newcall)]
2322-
ast = Expr(:lambda, newnames, Any[[], locals, []], body)
2322+
ast = Expr(:lambda, newnames, Any[[], locals, [], 0], body)
23232323
need_mod_annotate = false
2324+
needcopy = false
23242325
else
23252326
return NF
23262327
end
@@ -2435,7 +2436,7 @@ function inlineable(f::ANY, e::Expr, atype::ANY, sv::StaticVarInfo, enclosing_as
24352436
argexprs2 = t.args
24362437
icall = LabelNode(label_counter(body.args)+1)
24372438
partmatch = Expr(:gotoifnot, false, icall.label)
2438-
thrw = Expr(:call, :throw, Expr(:call, Main.Base.MethodError, (f, :inline), t))
2439+
thrw = Expr(:call, :throw, Expr(:call, TopNode(:MethodError), Expr(:call, top_tuple, e.args[1], QuoteNode(:inline)), t))
24392440
thrw.typ = Bottom
24402441
end
24412442

base/replutil.jl

+22-11
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,15 @@ showerror(io::IO, ex::AssertionError) = print(io, "AssertionError: $(ex.msg)")
123123

124124
function showerror(io::IO, ex::MethodError)
125125
print(io, "MethodError: ")
126-
name = isgeneric(ex.f) ? ex.f.env.name : :anonymous
127-
if isa(ex.f, DataType)
128-
print(io, "`$(ex.f)` has no method matching $(ex.f)(")
126+
if isa(ex.f, Tuple)
127+
f = ex.f[1]
128+
print(io, "<inline> ")
129+
else
130+
f = ex.f
131+
end
132+
name = isgeneric(f) ? f.env.name : :anonymous
133+
if isa(f, DataType)
134+
print(io, "`$(f)` has no method matching $(f)(")
129135
else
130136
print(io, "`$(name)` has no method matching $(name)(")
131137
end
@@ -138,10 +144,10 @@ function showerror(io::IO, ex::MethodError)
138144
i == length(ex.args) || print(io, ", ")
139145
end
140146
print(io, ")")
141-
# Check for local functions that shaddow methods in Base
147+
# Check for local functions that shadow methods in Base
142148
if isdefined(Base, name)
143-
f = eval(Base, name)
144-
if f !== ex.f && isgeneric(f) && applicable(f, ex.args...)
149+
basef = eval(Base, name)
150+
if basef !== f && isgeneric(basef) && applicable(basef, ex.args...)
145151
println(io)
146152
print(io, "you may have intended to import Base.$(name)")
147153
end
@@ -154,14 +160,14 @@ function showerror(io::IO, ex::MethodError)
154160
hasrows |= isrow
155161
push!(vec_args, isrow ? vec(arg) : arg)
156162
end
157-
if hasrows && applicable(ex.f, vec_args...)
163+
if hasrows && applicable(f, vec_args...)
158164
print(io, "\n\nYou might have used a 2d row vector where a 1d column vector was required.")
159165
print(io, "\nNote the difference between 1d column vector [1,2,3] and 2d row vector [1 2 3].")
160166
print(io, "\nYou can convert to a column vector with the vec() function.")
161167
end
162168
# Give a helpful error message if the user likely called a type constructor
163169
# and sees a no method error for convert
164-
if ex.f == Base.convert && !isempty(ex.args) && isa(ex.args[1], Type)
170+
if f == Base.convert && !isempty(ex.args) && isa(ex.args[1], Type)
165171
println(io)
166172
print(io, "This may have arisen from a call to the constructor $(ex.args[1])(...),")
167173
print(io, "\nsince type constructors fall back to convert methods.")
@@ -175,16 +181,21 @@ const UNSHOWN_METHODS = ObjectIdDict(
175181
function show_method_candidates(io::IO, ex::MethodError)
176182
# Displays the closest candidates of the given function by looping over the
177183
# functions methods and counting the number of matching arguments.
184+
if isa(ex.f, Tuple)
185+
f = ex.f[1]
186+
else
187+
f = ex.f
188+
end
178189

179190
lines = []
180191
# These functions are special cased to only show if first argument is matched.
181-
special = ex.f in [convert, getindex, setindex!]
182-
funcs = [ex.f]
192+
special = f in [convert, getindex, setindex!]
193+
funcs = [f]
183194

184195
# An incorrect call method produces a MethodError for convert.
185196
# It also happens that users type convert when they mean call. So
186197
# pool MethodErrors for these two functions.
187-
ex.f === convert && push!(funcs, call)
198+
f === convert && push!(funcs, call)
188199

189200
for func in funcs
190201
name = isgeneric(func) ? func.env.name : :anonymous

0 commit comments

Comments
 (0)