Lint.jl icon indicating copy to clipboard operation
Lint.jl copied to clipboard

Check for unused keyword arguments

Open jonniedie opened this issue 4 years ago • 0 comments

Only positional arguments are currently checked. It might also be worth adding an extra stern warning for unused keyword argument slurps, because they can cause silent failures on misspelled keyword arguments:

julia> badfun(;some_arg=1, another_arg=2, kwargs...) = some_arg*another_arg^2
badfun (generic function with 1 method)

julia> badfun(;another_arg=5)
25

julia> badfun(;anotherarg=5)
4

julia> betterfun(;some_arg=1, another_arg=2) = some_arg*another_arg^2
betterfun (generic function with 1 method)

julia> betterfun(;another_arg=5)
25

julia> betterfun(;anotherarg=5)
ERROR: MethodError: no method matching betterfun(; anotherarg=5)
Closest candidates are:
  betterfun(; some_arg, another_arg) at REPL[2]:1 got unsupported keyword argument "anotherarg"
Stacktrace: ...

jonniedie avatar Jun 05 '20 16:06 jonniedie