Inconsistent behaviour of argmax

An MWE:

julia> using Random

julia> a = rand(5, 5)
5×5 Matrix{Float64}:
 0.304673  0.659002   0.223237  0.189379  0.735553
 0.423152  0.844487   0.599046  0.60839   0.653539
 0.808406  0.146324   0.866515  0.717432  0.353227
 0.829093  0.0249944  0.501509  0.619801  0.542704
 0.458972  0.682252   0.762093  0.260897  0.611253

julia> argmax(a)
CartesianIndex(3, 3)

julia> argmax(x-> x<0.5 ? x : -Inf, a)
0.45897230687902646

julia> findmax(x-> x<0.5 ? x : -Inf, a)
(0.45897230687902646, CartesianIndex(5, 1))

julia> findmax(a)
(0.8665152659983258, CartesianIndex(3, 3))

Without predicate, argmax returns the index of the maximum value, but with predicate, it returns the value.
I’ve checked Julia 1.10.2 and 1.9.4, both with this behaviour.

You are right: `argmax` behaves differently from other higher-order functions · Issue #48502 · JuliaLang/julia · GitHub