Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

goretkin
Copy link
Contributor

@goretkin goretkin commented Aug 7, 2020

Attempt to [identify and] fix #36938

(dovetails with #36965) (already merged)

@vtjnash
Copy link
Member

vtjnash commented Nov 12, 2021

rebase, for a new CI run?

@goretkin
Copy link
Contributor Author

I rebased.


@testset "issue #36938" begin
# 👎 denotes tests that are broken.
@test findfirst(fill(true, (0, 2))) === nothing # 👎
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor Author

@goretkin goretkin Nov 12, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

findnext and degenerate multidimensional arrays
3 participants