Skip to content

Commit

Permalink
Add defalg methods to resolve potential dispatch ambiguities (JuliaLa…
Browse files Browse the repository at this point in the history
…ng#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 JuliaStrings/InlineStrings.jl#21
(and other custom types that will want to add `defalg` support allowing
for `Union` with `Missing`).
  • Loading branch information
bkamins authored and N5N3 committed Jan 24, 2022
1 parent 13b7f96 commit e836aed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e836aed

Please sign in to comment.