Skip to content

Commit fe82988

Browse files
authored
improve allunique's type stability (#56161)
Caught by aviatesk/JET.jl#667.
1 parent 0af99e6 commit fe82988

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

base/set.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ function allunique(A::StridedArray)
549549
if length(A) < 32
550550
_indexed_allunique(A)
551551
elseif OrderStyle(eltype(A)) === Ordered()
552-
a1, rest1 = Iterators.peel(A)
553-
a2, rest = Iterators.peel(rest1)
552+
a1, rest1 = Iterators.peel(A)::Tuple{Any,Any}
553+
a2, rest = Iterators.peel(rest1)::Tuple{Any,Any}
554554
if !isequal(a1, a2)
555555
compare = isless(a1, a2) ? isless : (a,b) -> isless(b,a)
556556
for a in rest

test/sets.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ end
644644
@test !allunique((NaN, NaN))
645645
# Known length 1, need not evaluate:
646646
@test allunique(error(x) for x in [1])
647+
# @test_opt allunique(Int[])
647648
end
648649

649650
@testset "allunique(f, xs)" begin

0 commit comments

Comments
 (0)