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

invoke should raise MethodError for ambiguous cases #18095

Closed
StefanKarpinski opened this issue Aug 17, 2016 · 3 comments · Fixed by #23603
Closed

invoke should raise MethodError for ambiguous cases #18095

StefanKarpinski opened this issue Aug 17, 2016 · 3 comments · Fixed by #23603
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch
Milestone

Comments

@StefanKarpinski
Copy link
Member

Currently we have this:

julia> f(::Int, ::Number) = 1
f (generic function with 1 method)

julia> f(::Number, ::Int) = 2
f (generic function with 2 methods)

julia> f(1,2)
ERROR: MethodError: f(::Int64, ::Int64) is ambiguous. Candidates:
  f(::Number, ::Int64) at REPL[1]:1
  f(::Int64, ::Number) at REPL[0]:1

julia> invoke(f, (Int,Int), 1, 2)
1

When invoke is called with an ambiguous tuple of types, it should raise the same error as when the function is simply called with arguments of those types. Discovered while playing with the @invoke macro I cooked up here.

@StefanKarpinski StefanKarpinski added bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch labels Aug 17, 2016
@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Aug 17, 2016
@StefanKarpinski
Copy link
Member Author

Was that a mis-reference, @vtjnash?

@vtjnash
Copy link
Member

vtjnash commented Aug 18, 2016

no, I simply elected to fix the occurrence there without also fixing it here

@tkelman tkelman modified the milestones: 1.0, 0.6.0 Jan 5, 2017
@tkelman
Copy link
Contributor

tkelman commented Jan 5, 2017

invoke behavior seems unlikely to change for 0.6

@vtjnash vtjnash self-assigned this Sep 5, 2017
vtjnash added a commit that referenced this issue Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants