Consider the following:
julia> kwargs = Dict(:a => 0)
Dict{Symbol, Int64} with 1 entry:
:a => 0
julia> f(; a=1) = a
f (generic function with 1 method)
julia> f(; a=2, kwargs...)
0
julia> f(; a=2, a=0)
ERROR: syntax: keyword argument "a" repeated in call to "f"
Is that expected behavior, or should I report that as a bug? I would have expected f(; a=2, kwargs...)
to throw the same error as f(; a=2, a=0)
. Is there a way to avoid this foot-gun, and have Julia detect duplicate keyword arguments when there’s splatting involved? It doesn’t seem to matter whether kwargs
is a Dict{Symbol, Int64}
or a Tuple{Pair{Symbol, Int64}}
.