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

remove convert method for Any? #51

Open
JeffBezanson opened this issue Dec 19, 2018 · 4 comments · May be fixed by #52
Open

remove convert method for Any? #51

JeffBezanson opened this issue Dec 19, 2018 · 4 comments · May be fixed by #52

Comments

@JeffBezanson
Copy link

As in JuliaData/CategoricalArrays.jl#177, the method

Base.convert(::Type{Any}, ::DataValue{Union{}}) = NA

causes a lot of recompilation. IIUC, NA is a singleton and so this method is not different from the default conversion to Any in Base?

@davidanthoff
Copy link
Member

convert(Any, NA) throws a method ambiguity error without it...

@JeffBezanson
Copy link
Author

Works for me on master. What's the full error output you get?

@davidanthoff
Copy link
Member

julia> convert(Any, NA)
ERROR: MethodError: convert(::Type{Any}, ::DataValue{Union{}}) is ambiguous. Candidates:
  convert(::Type{Union{Missing, T}}, ::DataValue{Union{}}) where T in DataValues at C:\Users\david\.julia\dev\DataValues\src\scalar\core.jl:38
  convert(::Type{Any}, x) in Base at essentials.jl:153
Possible fix, define
  convert(::Type{Any}, ::DataValue{Union{}})
Stacktrace:
 [1] top-level scope at none:0

@pfitzseb
Copy link

This also causes issues when trying to put a DataValue{Any} into Any-typed containers, e.g.

julia> dv = DataValue{Any}("asd")
DataValue{Any}("asd")

julia> c = Channel(0)
Channel{Any}(sz_max:0,sz_curr:0)

julia> put!(c, dv)
ERROR: MethodError: convert(::Type{Any}, ::DataValue{Any}) is ambiguous. Candidates:
  convert(::Type{Any}, x) in Base at essentials.jl:170
  convert(::Type{Union{Missing, T}}, value::DataValue{T}) where T in DataValues at /home/pfitzseb/.julia/packages/DataValues/N7oeL/src/scalar/core.jl:40
  convert(::Type{T}, x::T) where T>:Union{Missing, Nothing} in Base at missing.jl:68
To resolve the ambiguity, try making one of the methods more specific, or adding a new method more specific than any of the existing applicable methods.
Stacktrace:
 [1] put!(::Channel{Any}, ::DataValue{Any}) at ./channels.jl:311
 [2] top-level scope at REPL[5]:1

on 1.5 or

julia> dv = DataValue{Any}("asd")
Error showing value of type DataValue{Any}:
ERROR: MethodError: convert(::Type{Any}, ::DataValue{Any}) is ambiguous. Candidates:
  convert(::Type{Any}, x) in Base at essentials.jl:204
  convert(::Type{T}, x::T) where T>:Union{Missing, Nothing} in Base at missing.jl:68
  convert(::Type{T}, x::T) where T>:Nothing in Base at some.jl:35
  convert(::Type{T}, x) where T>:Union{Missing, Nothing} in Base at missing.jl:70
  convert(::Type{T}, x) where T>:Nothing in Base at some.jl:36
  convert(::Type{Union{Missing, T}}, value::DataValue{T}) where T in DataValues at /home/pfitzseb/.julia/packages/DataValues/N7oeL/src/scalar/core.jl:40
To resolve the ambiguity, try making one of the methods more specific, or adding a new method more specific than any of the existing applicable methods.
Stacktrace:
  [1] Base.RefValue{Any}(x::DataValue{Any})
    @ Base ./refvalue.jl:8
  [2] Ref{Any}(x::DataValue{Any})
    @ Base ./refpointer.jl:136
  [3] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/Documents/Git/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:212
  [4] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/Documents/Git/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:225

on master.

That first error is also the cause of julia-vscode/julia-vscode#1940.

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

Successfully merging a pull request may close this issue.

3 participants