Skip to content

methods(f) not showing correct signatures for functions with default arguments #49028

@henrik-wolf

Description

@henrik-wolf

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]:1

When 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]:1

I 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 cores

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions