Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defalg method ambiguity #21

Closed
DrChainsaw opened this issue Dec 14, 2021 · 5 comments
Closed

defalg method ambiguity #21

DrChainsaw opened this issue Dec 14, 2021 · 5 comments

Comments

@DrChainsaw
Copy link

It seems like there is a method ambiguity when InlineStrings is added.

One example where it popped up in the wild: JuliaParallel/Dagger.jl#315

julia> tuple() |> collect |> sort
Union{}[]

julia> sort([missing, missing])
2-element Vector{Missing}:
 missing
 missing

julia> using InlineStrings

julia> tuple() |> collect |> sort
ERROR: MethodError: defalg(::Vector{Union{}}) is ambiguous. Candidates:
  defalg(v::AbstractArray{<:Union{Missing, Number}}) in Base.Sort at sort.jl:658
  defalg(::AbstractArray{<:Union{Missing, String1, String15, String3, String7}}) in InlineStrings at \.julia\packages\InlineStrings\aWvyB\src\InlineStrings.jl:698
Possible fix, define
  defalg(::AbstractArray{<:Missing})

julia> sort([missing, missing])
ERROR: MethodError: defalg(::Vector{Missing}) is ambiguous. Candidates:
etc...
@bkamins
Copy link

bkamins commented Dec 15, 2021

This is a bug in Julia Base, but for the time being unfortunately it has to be resolved in InlineStrings.jl.

@quinnj I propose to define the following methods:

defalg(::AbstractArray{Union{Missing, String1}})
defalg(::AbstractArray{Union{Missing, String3}})
defalg(::AbstractArray{Union{Missing, String7}})
defalg(::AbstractArray{Union{Missing, String15}})
defalg(::AbstractArray{String1})
defalg(::AbstractArray{String3})
defalg(::AbstractArray{String7})
defalg(::AbstractArray{String15})

which should resolve the issue.

bkamins added a commit to bkamins/julia that referenced this issue Dec 15, 2021
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`).

Preferably this should be backported I think.
@bkamins
Copy link

bkamins commented Dec 15, 2021

JuliaLang/julia#43426

@epatters
Copy link

epatters commented Jan 4, 2022

Just ran into this one myself. Hopefully a workaround can be merged soon.

vtjnash pushed a commit to JuliaLang/julia that referenced this issue Jan 18, 2022
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`).
N5N3 pushed a commit to N5N3/julia that referenced this issue Jan 24, 2022
…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`).
@caseykneale
Copy link

Similar story here:

ERROR: LoadError: MethodError: defalg(::Vector{Union{}}) is ambiguous. Candidates:
  defalg(v::AbstractArray{var"#s832", N} where {var"#s832"<:Union{Missing, Number}, N}) in Base.Sort at sort.jl:653
  defalg(::AbstractArray{var"#s86", N} where {var"#s86"<:Union{Missing, InlineStrings.String1, InlineStrings.String15, InlineStrings.String3, InlineStrings.String7}, N}) in InlineStrings at /home/runner/.julia/packages/InlineStrings/F5Dhz/src/InlineStrings.jl:698
Possible fix, define
  defalg(::AbstractArray{var"#s86", N} where {var"#s86"<:Missing, N})

Looks like the patch to Base got merged, but likely won't be back-ported?

KristofferC pushed a commit to JuliaLang/julia that referenced this issue Feb 15, 2022
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`).

(cherry picked from commit eb724e0)
KristofferC pushed a commit to JuliaLang/julia that referenced this issue Feb 19, 2022
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`).

(cherry picked from commit eb724e0)
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Feb 22, 2022
…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`).
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Mar 8, 2022
…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`).
@quinnj
Copy link
Member

quinnj commented Apr 19, 2022

This was backported to 1.7

@quinnj quinnj closed this as completed Apr 19, 2022
staticfloat pushed a commit to JuliaLang/julia that referenced this issue Dec 23, 2022
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`).

(cherry picked from commit eb724e0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants