-
-
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
[WIP] find*
bounds checking
#36967
base: master
Are you sure you want to change the base?
[WIP] find*
bounds checking
#36967
Conversation
rebase, for a new CI run? |
385ff5e
to
89d9ccc
Compare
I rebased. |
|
||
@testset "issue #36938" begin | ||
# 👎 denotes tests that are broken. | ||
@test findfirst(fill(true, (0, 2))) === nothing # 👎 |
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.
Shouldn't these use @test_broken
with the correct answer then?
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.
Looks like all lines with 👎 are currently throwing a BoundsError so this PR is failing CI
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.
I've lost track of what needs to happen here. I think my goal was to write tests that should pass, but I don't remember if the current (inconsistent) behavior can be fixed before Julia 2.0, e.g.:
julia> findfirst(fill(true, (0,)))
julia> findfirst(fill(true, (1, 0)))
julia> findfirst(fill(true, (0, 1)))
julia> findfirst(fill(true, (2, 0)))
julia> findfirst(fill(true, (0, 2)))
ERROR: BoundsError: attempt to access 0×2 Matrix{Bool} at index [1, 1]
Obviously failing CI does not help.
I've long wanted a macro like the one below, then I could write these as @test_broken
:
julia> macro error_as_value(ex)
quote
try
return Some($(ex))
catch e
return e
end
end
end
@error_as_value (macro with 1 method)
julia> @error_as_value sqrt(4)
Some(2.0)
julia> @error_as_value sqrt(-4)
DomainError(-4.0, "sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).")
What do people think of that idea? Ideas for a better name?
Attempt to [identify and] fix #36938
(dovetails with #36965)(already merged)