-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error hint for incorrect stacked indexing (#40934)
A common entry level mistake is to try to index a matrix with two sets of brackets, e.g. `a = [1 2; 3 4]; a[1][2] = 5` This will lead to an error that `setindex!()` on the element type of `a` is missing. This PR adds an error hint for the case where a MethodError is raised when `setindex!` is called with a `Number` as the first argument. I considered going broader than numbers, but it seems more likely that this kind of mistake would happen when working with simple number arrays vs. something more advanced. Could also consider if it is possible to do the same for when `getindex()` is called on a `Number`, which emits a BoundsError. Co-authored-by: Michael Abbott <[email protected]>
- Loading branch information
1 parent
b3b2736
commit c19c68e
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters