Skip to content

Commit 454fc51

Browse files
committed
argmin ranges bug: you cannot pass an unsorted array to searchsorted
1 parent 58fba2b commit 454fc51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/range.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ function argmin(r::AbstractRange)
705705
elseif step(r) > 0
706706
firstindex(r)
707707
else
708-
first(searchsorted(r, last(r)))
708+
lastindex(r)
709709
end
710710
end
711711

@@ -720,7 +720,7 @@ function argmax(r::AbstractRange)
720720
if isempty(r)
721721
throw(ArgumentError("range must be non-empty"))
722722
elseif step(r) > 0
723-
first(searchsorted(r, last(r)))
723+
lastindex(r)
724724
else
725725
firstindex(r)
726726
end

0 commit comments

Comments
 (0)