Commit 4ec13f5
authored
Make callable-related MethodError messages more descriptive (#57815)
Addresses #57807 to some
extent, although the error message may be improved further.
On nightly,
```julia
julia> stack(1:3, 1:3)
ERROR: MethodError: objects of type UnitRange{Int64} are not callable
Use square brackets [] for indexing an Array.
The object of type `UnitRange{Int64}` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
```
The second sentence seems unrelated to the first, and the source of the
error remains unclear from the message.
This PR makes the message more verbose, and provides pointers.
```julia
julia> stack(1:3, 200)
ERROR: MethodError: objects of type UnitRange{Int64} are not callable.
In case you did not try calling it explicitly, check if a UnitRange{Int64} has been passed as an argument to a method that expects a callable instead.
In case you're trying to index into the array, use square brackets [] instead of parentheses ().
The object of type `UnitRange{Int64}` exists, but no method is defined for this combination of argument types when trying to treat it as a callable object.
```1 parent 4050b97 commit 4ec13f5
2 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| |||
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
326 | | - | |
| 328 | + | |
327 | 329 | | |
328 | 330 | | |
329 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
423 | 426 | | |
424 | 427 | | |
425 | 428 | | |
| |||
0 commit comments