Skip to content

Commit 0701125

Browse files
inkydragonLilithHafner
authored andcommitted
fix generic findall(A) (JuliaLang#43089)
Fixes JuliaLang#43078; This problem was introduced by JuliaLang#36965
1 parent 3a77ae2 commit 0701125

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

base/array.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,9 @@ julia> findall(falses(3))
23242324
Int64[]
23252325
```
23262326
"""
2327-
findall(A) = findall(identity, A)
2327+
function findall(A)
2328+
collect(first(p) for p in pairs(A) if last(p))
2329+
end
23282330

23292331
# Allocating result upfront is faster (possible only when collection can be iterated twice)
23302332
function findall(A::AbstractArray{Bool})

test/arrayops.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ end
594594
@test findprev(b, T(1)) isa keytype(b)
595595
@test findprev(b, T(2)) isa keytype(b)
596596
end
597+
598+
@testset "issue 43078" begin
599+
@test_throws TypeError findall([1])
600+
end
597601
end
598602
@testset "find with Matrix" begin
599603
A = [1 2 0; 3 4 0]

0 commit comments

Comments
 (0)