@@ -123,9 +123,15 @@ showerror(io::IO, ex::AssertionError) = print(io, "AssertionError: $(ex.msg)")
123
123
124
124
function showerror (io:: IO , ex:: MethodError )
125
125
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) (" )
129
135
else
130
136
print (io, " `$(name) ` has no method matching $(name) (" )
131
137
end
@@ -138,10 +144,10 @@ function showerror(io::IO, ex::MethodError)
138
144
i == length (ex. args) || print (io, " , " )
139
145
end
140
146
print (io, " )" )
141
- # Check for local functions that shaddow methods in Base
147
+ # Check for local functions that shadow methods in Base
142
148
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... )
145
151
println (io)
146
152
print (io, " you may have intended to import Base.$(name) " )
147
153
end
@@ -154,14 +160,14 @@ function showerror(io::IO, ex::MethodError)
154
160
hasrows |= isrow
155
161
push! (vec_args, isrow ? vec (arg) : arg)
156
162
end
157
- if hasrows && applicable (ex . f, vec_args... )
163
+ if hasrows && applicable (f, vec_args... )
158
164
print (io, " \n\n You might have used a 2d row vector where a 1d column vector was required." )
159
165
print (io, " \n Note the difference between 1d column vector [1,2,3] and 2d row vector [1 2 3]." )
160
166
print (io, " \n You can convert to a column vector with the vec() function." )
161
167
end
162
168
# Give a helpful error message if the user likely called a type constructor
163
169
# 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)
165
171
println (io)
166
172
print (io, " This may have arisen from a call to the constructor $(ex. args[1 ]) (...)," )
167
173
print (io, " \n since type constructors fall back to convert methods." )
@@ -175,16 +181,21 @@ const UNSHOWN_METHODS = ObjectIdDict(
175
181
function show_method_candidates (io:: IO , ex:: MethodError )
176
182
# Displays the closest candidates of the given function by looping over the
177
183
# 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
178
189
179
190
lines = []
180
191
# 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]
183
194
184
195
# An incorrect call method produces a MethodError for convert.
185
196
# It also happens that users type convert when they mean call. So
186
197
# pool MethodErrors for these two functions.
187
- ex . f === convert && push! (funcs, call)
198
+ f === convert && push! (funcs, call)
188
199
189
200
for func in funcs
190
201
name = isgeneric (func) ? func. env. name : :anonymous
0 commit comments