# Passing duplicate key in function through \`kwargs\` doesn't error

**URL:** <https://discourse.julialang.org/t/passing-duplicate-key-in-function-through-kwargs-doesnt-error/107870>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [December 20, 2023, 5:51pm UTC](https://discourse.julialang.org/t/passing-duplicate-key-in-function-through-kwargs-doesnt-error/107870 "2023-12-20T17:51:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [December 20, 2023, 5:51pm UTC](https://discourse.julialang.org/t/passing-duplicate-key-in-function-through-kwargs-doesnt-error/107870/1 "2023-12-20T17:51:14Z")

</div>

If in Julia I try to do something like this, I’m rightly stopped by the program:

```julia
julia> f(; x, x) = x
ERROR: syntax: function argument name not unique: "x" around REPL[1]:1
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

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

julia> f(; x = 2, x = 4)
ERROR: syntax: keyword argument "x" repeated in call to "f" around REPL[3]:1
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

```

But this instead is allowed, which seems strange/contradictory to me:

```julia
julia> f(; x, kwargs...) = x
f (generic function with 1 method)

julia> kwargs = (x = 4,)
(x = 4,)

julia> f(; x = 2, kwargs...)
4

```

So…is this a bug or a feature? 😃

edit:

Actually it works also if you use as a definition of `f` only `f(; x) = x`, which is even weirder:

```julia
julia> f(; x) = x
f (generic function with 1 method)

julia> kwargs = (x = 4,)
(x = 4,)

julia> f(; x = 2, kwargs...)
4

```

* * *

Tried both in 1.9.4 and 1.10-rc3

---

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [December 20, 2023, 6:09pm UTC](https://discourse.julialang.org/t/passing-duplicate-key-in-function-through-kwargs-doesnt-error/107870/2 "2023-12-20T18:09:46Z")

</div>

It is a feature: [Splatted keywords take precedence · Issue #17785 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/17785)
