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

Lots of ambiguity errors on v0.5 #882

Closed
tlnagy opened this issue Aug 23, 2016 · 1 comment
Closed

Lots of ambiguity errors on v0.5 #882

tlnagy opened this issue Aug 23, 2016 · 1 comment

Comments

@tlnagy
Copy link
Member

tlnagy commented Aug 23, 2016

Due to JuliaLang/julia#6190, v0.5 throws a MethodError when function calls are ambiguous. This has come up recently in #881 and in #871. This kind of error is everywhere where we have aliased geometries (e.g. histogram, path, etc):

julia> Pkg.installed("Gadfly")
v"0.4.3+"

julia> using Gadfly

julia> plot(x=1:10, y=1:10, Geom.path,
                   Guide.xlabel("foo"), Guide.ylabel("bar"))
ERROR: MethodError: Gadfly.#plot(::Array{Any,1}, ::Gadfly.#plot, ::Gadfly.Geom.#path, ::Gadfly.Guide.XLabel, ::Gadfly.Guide.YLabel) is ambiguous. Candidates:
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, f::Function, a, b, elements::Union{DataType,Function,Gadfly.Element,Gadfly.Theme}...)
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, elements::Union{Array{Gadfly.Layer,1},Union{DataType,Function,Gadfly.Element,Gadfly.Theme}}...)

julia> plot(x=1:10, y=1:10, Geom.histogram,
                   Guide.xlabel("foo"), Guide.ylabel("bar"))
ERROR: MethodError: Gadfly.#plot(::Array{Any,1}, ::Gadfly.#plot, ::Gadfly.Geom.#histogram, ::Gadfly.Guide.XLabel, ::Gadfly.Guide.YLabel) is ambiguous. Candidates:
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, f::Function, a, b, elements::Union{DataType,Function,Gadfly.Element,Gadfly.Theme}...)
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, elements::Union{Array{Gadfly.Layer,1},Union{DataType,Function,Gadfly.Element,Gadfly.Theme}}...)

julia> plot(x=1:10, y=1:10, Geom.step,
                   Guide.xlabel("foo"), Guide.ylabel("bar"))
ERROR: MethodError: Gadfly.#plot(::Array{Any,1}, ::Gadfly.#plot, ::Gadfly.Geom.#step, ::Gadfly.Guide.XLabel, ::Gadfly.Guide.YLabel) is ambiguous. Candidates:
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, f::Function, a, b, elements::Union{DataType,Function,Gadfly.Element,Gadfly.Theme}...)
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, elements::Union{Array{Gadfly.Layer,1},Union{DataType,Function,Gadfly.Element,Gadfly.Theme}}...)

julia> plot(x=1:10, y=1:10, color=1:10, Geom.histogram2d,
                   Guide.xlabel("foo"), Guide.ylabel("bar"))
ERROR: MethodError: Gadfly.#plot(::Array{Any,1}, ::Gadfly.#plot, ::Gadfly.Geom.#histogram2d, ::Gadfly.Guide.XLabel, ::Gadfly.Guide.YLabel) is ambiguous. Candidates:
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, f::Function, a, b, elements::Union{DataType,Function,Gadfly.Element,Gadfly.Theme}...)
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, elements::Union{Array{Gadfly.Layer,1},Union{DataType,Function,Gadfly.Element,Gadfly.Theme}}...)

julia> plot(x=1:10, y=1:10, color=1:10, Geom.density,
                   Guide.xlabel("foo"), Guide.ylabel("bar"))
ERROR: MethodError: Gadfly.#plot(::Array{Any,1}, ::Gadfly.#plot, ::Gadfly.Geom.#density, ::Gadfly.Guide.XLabel, ::Gadfly.Guide.YLabel) is ambiguous. Candidates:
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, f::Function, a, b, elements::Union{DataType,Function,Gadfly.Element,Gadfly.Theme}...)
  (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, elements::Union{Array{Gadfly.Layer,1},Union{DataType,Function,Gadfly.Element,Gadfly.Theme}}...)

Non-aliased geometries work fine. Currently, the only way around this is by changing Geom.histogram to Geom.histogram(), which prevent the ambiguity by returning a Geometry object instead of a Function. This error is due to the untyped a and b in (::Gadfly.#kw##plot)(::Array{Any,1}, ::Gadfly.#plot, f::Function, a, b, elements::Union{DataType,Function,Gadfly.Element,Gadfly.Theme}...) causing issues when dispatching.

@shashi
Copy link
Collaborator

shashi commented Aug 24, 2016

Should probably add one of these as test for #883?

@shashi shashi closed this as completed in 24f5d93 Aug 25, 2016
shashi added a commit that referenced this issue Aug 25, 2016
add stronger typing to poetic plotting, fixes #882
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

2 participants