From eb724e0065bdcc50da103d00f4a9e98757cdb5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Tue, 18 Jan 2022 19:33:12 +0100 Subject: [PATCH] Add defalg methods to resolve potential dispatch ambiguities (#43426) We could also consider adding `defalg(v::AbstractArray{<:Number}) = DEFAULT_UNSTABLE`, but it is unlikely that someone will want to do `Union` of `<:Number` and something other than `Missing` that still would support comparison. Relevant for https://github.com/JuliaStrings/InlineStrings.jl/issues/21 (and other custom types that will want to add `defalg` support allowing for `Union` with `Missing`). --- base/sort.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/sort.jl b/base/sort.jl index bfa3e1d0dc0e2..0f3499320b212 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -656,6 +656,8 @@ end defalg(v::AbstractArray) = DEFAULT_STABLE defalg(v::AbstractArray{<:Union{Number, Missing}}) = DEFAULT_UNSTABLE +defalg(v::AbstractArray{Missing}) = DEFAULT_UNSTABLE +defalg(v::AbstractArray{Union{}}) = DEFAULT_UNSTABLE function sort!(v::AbstractVector, alg::Algorithm, order::Ordering) inds = axes(v,1)