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

method ambiguities in latest doc is old #16630

Closed
zhmz90 opened this issue May 28, 2016 · 3 comments
Closed

method ambiguities in latest doc is old #16630

zhmz90 opened this issue May 28, 2016 · 3 comments
Labels
domain:docs This change adds or pertains to documentation

Comments

@zhmz90
Copy link
Contributor

zhmz90 commented May 28, 2016

I am not sure whether it is the doc in Method Ambiguities old or there is a bug in the current implementation. For me, I prefer reporting error with method ambiguities when you just have defined them while not the time when you make a call:

My latest Julia repl displays:

julia> g(x::Float64, y) = 2x + y;

julia> g(x, y::Float64) = x + 2y;

julia> g(2.0, 3)
7.0

julia> g(2, 3.0)
8.0

julia> g(2.0, 3.0)
ERROR: MethodError: g(::Float64, ::Float64) is ambiguous. Candidates:
  svec(Tuple{#g,Float64,Float64},svec(),g(x, y::Float64) at REPL[10]:1)
  svec(Tuple{#g,Float64,Float64},svec(),g(x::Float64, y) at REPL[9]:1)
 in eval(::Module, ::Any) at ./boot.jl:225
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46

while the expected is:

julia> g(x::Float64, y) = 2x + y;

julia> g(x, y::Float64) = x + 2y;
WARNING: New definition
    g(Any, Float64) at none:1
is ambiguous with:
    g(Float64, Any) at none:1.
To fix, define
    g(Float64, Float64)
before the new definition.

julia> g(2.0, 3)
7.0

julia> g(2, 3.0)
8.0

julia> g(2.0, 3.0)
7.0

My Julia version is:

julia> versioninfo()
Julia Version 0.5.0-dev+4370
Commit 758aebc* (2016-05-27 21:34 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
@KristofferC
Copy link
Sponsor Member

This is intended. #16125

@nalimilan
Copy link
Member

But there's still a bug in the docs. I've checked the message isn't up-to-date in git master.

@nalimilan nalimilan reopened this May 28, 2016
@nalimilan nalimilan added the domain:docs This change adds or pertains to documentation label May 28, 2016
@zhmz90 zhmz90 changed the title Bug with method ambiguities method ambiguities in latest doc is old May 29, 2016
iglpdc added a commit to iglpdc/julia that referenced this issue Jun 25, 2016
The way of handling method ambiguities changed in JuliaLang#16125. Now Julia throws
an error when calling an ambiguous methods, instead of just
giving a warning when it was defined. This updates the manual to reflect
the change.

Fixes JuliaLang#16630.
iglpdc added a commit to iglpdc/julia that referenced this issue Jun 25, 2016
The way of handling method ambiguities changed in JuliaLang#16125. Now Julia throws
an error when calling an ambiguous methods, instead of just
giving a warning when it was defined. This updates the manual to reflect
the change.

Fixes JuliaLang#16630.
@KristofferC
Copy link
Sponsor Member

Docs should be updated now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

4 participants