-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Add index hint to BoundsError message #43815
base: master
Are you sure you want to change the base?
Changes from 1 commit
2b4bc40
fb986ec
6a2a0e4
93bc6b7
06f7525
30e07e2
d2c850c
a660b27
c1eb7e9
cb939a3
3a161bf
2c880d6
61b7d15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2900,29 +2900,29 @@ end | |||||
b = IOBuffer() | ||||||
showerror(b, err) | ||||||
@test String(take!(b)) == | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, 1:2]" | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, 1:2].\nLegal indices are [1:2, 1:2]." | ||||||
|
||||||
err = try x[10, trues(2)]; catch err; err; end | ||||||
b = IOBuffer() | ||||||
showerror(b, err) | ||||||
@test String(take!(b)) == | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, 2-element BitVector]" | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, 2-element BitVector].\nLegal indices are [1:2, 1:2]." | ||||||
|
||||||
# Also test : directly for custom types for which it may appear as-is | ||||||
err = BoundsError(x, (10, :)) | ||||||
showerror(b, err) | ||||||
@test String(take!(b)) == | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, :]" | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, :].\nLegal indices are [1:3, 1:3]." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gustaphe Thank you for your contribution and welcome to the community. This does make error messege clearer! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I have a hard time running the tests, they end up running my laptop's memory into the ground and causing a reboot. I thought I found a subset of the tests that would catch everything but sadly some slipped through. I don't want it to seem like I'm brute force debugging this by spamming commits, but I don't have any other method of knowing it works so I kind of am. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is okay to brute force it with CI time. We usually have a little bit of excess. This seems like a good idea. It might conflict eventually with #43738, but let's cross the bridge later, and hopefully merge this sooner. |
||||||
|
||||||
err = BoundsError(x, "bad index") | ||||||
showerror(b, err) | ||||||
@test String(take!(b)) == | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [\"bad index\"]" | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [\"bad index\"].\nLegal indices are [1:2, 1:2]." | ||||||
|
||||||
err = BoundsError(x, (10, "bad index")) | ||||||
showerror(b, err) | ||||||
@test String(take!(b)) == | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, \"bad index\"]" | ||||||
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, \"bad index\"].\nLegal indices are [1:2, 1:2]." | ||||||
end | ||||||
|
||||||
@testset "inference of Union{T,Nothing} arrays 26771" begin | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not consistently print as
start:stop
no matter then length like before? Also forTuple
below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. Just a style choice but it didn't really matter to me. I'll fix.
(Note to self: Strings)