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 deletion ambiguity recomputation fails for Union #28899

Closed
timholy opened this issue Aug 26, 2018 · 0 comments
Closed

Method deletion ambiguity recomputation fails for Union #28899

timholy opened this issue Aug 26, 2018 · 0 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@timholy
Copy link
Member

timholy commented Aug 26, 2018

#25050 recomputed ambiguities but clearly missed a case:

julia> struct A end

julia> struct B end

julia> foo(a::Union{Nothing, A}) = 1
foo (generic function with 1 method)

julia> foo(a::Union{Nothing, B}) = 2
foo (generic function with 2 methods)

julia> mths = methods(foo)
# 2 methods for generic function "foo":
[1] foo(a::Union{Nothing, A}) in Main at REPL[3]:1
[2] foo(a::Union{Nothing, B}) in Main at REPL[4]:1

julia> Base.delete_method(first(mths))

julia> methods(foo)
# 1 method for generic function "foo":
[1] foo(a::Union{Nothing, B}) in Main at REPL[4]:1

julia> foo(nothing)
ERROR: MethodError: foo(::Nothing) is ambiguous. Candidates:
  foo(a::Union{Nothing, A}) in Main at REPL[3]:1
  foo(a::Union{Nothing, B}) in Main at REPL[4]:1
Possible fix, define
  foo(::Nothing)
Stacktrace:
 [1] top-level scope at none:0

(It works fine if you delete first and then define the B method.)

timholy added a commit to timholy/Revise.jl that referenced this issue Sep 5, 2018
This works around JuliaLang/julia#28899
and probably fixes #137

New tests:

- test JuliaLang/julia#28899
- test for signature-changes with a gensymmed type
- test that changes that do not fundamentally change the type signature
  do not result in inadvertent deletion (probably #137).
timholy added a commit to timholy/Revise.jl that referenced this issue Sep 5, 2018
This works around JuliaLang/julia#28899
and probably fixes #137

New tests:

- test JuliaLang/julia#28899
- test for signature-changes with a gensymmed type
- test that changes that do not fundamentally change the type signature
  do not result in inadvertent deletion (probably #137).
@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Sep 5, 2018
KristofferC pushed a commit that referenced this issue Sep 12, 2018
KristofferC pushed a commit that referenced this issue Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

2 participants