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 with empty arg list not overwritten by definition of keyword-only method (with no defaults) #38066

Closed
klaff opened this issue Oct 16, 2020 · 1 comment

Comments

@klaff
Copy link
Contributor

klaff commented Oct 16, 2020

See https://discourse.julialang.org/t/im-confused-about-methods/48508/4

In the following snippet, when f()=1 is defined, it should overwrite the previous f(;a)=2 (because dispatch should only be performed on the positional arguments and both of these have no positional arguments). The methods function incorrectly indicates the wrong method survived, and both methods appear to be reachable. Per the discourse discussion, there is some debate on these points!

C:\Users\klaff>julia -q
julia> f(;a)=2
f (generic function with 1 method)

julia> f()=1
f (generic function with 1 method)

julia> methods(f)
# 1 method for generic function "f":
[1] f(; a) in Main at REPL[2]:1

julia> f()
1

julia> f(a=1)
2

julia>
@yuyichao
Copy link
Contributor

Dup of #9498

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