Skip to content

CategoricalArrays reveals possible ml_matches sorting bug #35187

@vtjnash

Description

@vtjnash

Doing some analysis work on serialization shakes out some issues sometimes. This one is a ml_matches mistake I observed, where in the precompile session, we're missing the third method in this list (after reload in the current session, all four start getting listed).

julia> M = [
       Tuple{typeof(Base.convert), Type{Union{Nothing, S}}, T} where T<:(Union{CategoricalArrays.CategoricalString{R}, CategoricalArrays.CategoricalValue{T, R} where T} where R) where S
       Tuple{typeof(Base.convert), Type{T}, T} where Nothing<:T<:Any
       Tuple{typeof(Base.convert), Type{S}, T} where T<:(Union{CategoricalArrays.CategoricalString{R}, CategoricalArrays.CategoricalValue{T, R} where T} where R) where S
       Tuple{typeof(Base.convert), Type{T}, Any} where Nothing<:T<:Any
       ]

julia> ms(T, S) = ccall(:jl_type_morespecific, Cint, (Any, Any), T, S)

julia> R = Tuple{typeof(Base.convert), Type{Union{Nothing, Module}}, Any}

julia> [typeintersect(M[i], M[j]) for i = 1:4, j = 1:4]
4×4 Array{UnionAll,2}:
 Tuple{typeof(convert),Type{Union{Nothing, S}},T} where T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) where S    Tuple{typeof(convert),Type{Union{Nothing, S}},T} where T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) where S
 Tuple{typeof(convert),Type{Union{Nothing, S}},Union{Nothing, S}} where S                                                                   Tuple{typeof(convert),Type{T},T} where T>:Nothing
 Tuple{typeof(convert),Type{Union{Nothing, S}},T} where T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) where S     Tuple{typeof(convert),Type{S},T} where T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) where S>:Nothing
 Tuple{typeof(convert),Type{Union{Nothing, S}},T} where T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) where S     Tuple{typeof(convert),Type{T},Any} where T>:Nothing

julia> [ms(M[i], M[j]) for i = 1:4, j = 1:4]
4×4 Array{Int32,2}:
 0  1  1  1
 0  0  0  1
 0  0  0  0
 0  0  0  0

julia> [R <: typeintersect(M[i], M[j]) for i = 1:4, j = 1:4]
4×4 Array{Bool,2}:
 0  0  0  0
 0  0  0  0
 0  0  0  0
 0  0  0  1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions