-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Description
I just came across this strange behaviour of methods, which does seem like a bug to me... When I create a function with a default argument in one line, methods drops everything behind it, when showing the signature:
julia> function test(a=1; b)
@show a
@show b
end
test (generic function with 2 methods)
julia> methods(test)
# 2 methods for generic function "test":
[1] test() in Main at REPL[1]:1
[2] test(a; b) in Main at REPL[1]:1When I create the (to my understanding equivalent) function in two steps, everything looks as I would expect it:
julia> function test(a; b)
@show a
@show b
end
test (generic function with 1 method)
julia> test(; b) = test(1; b=b)
test (generic function with 2 methods)
julia> methods(test)
# 2 methods for generic function "test":
[1] test(; b) in Main at REPL[2]:1
[2] test(a; b) in Main at REPL[1]:1I installed julia with juliaup, here is the versioninfo:
julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
Threads: 1 on 8 virtual coresReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels