# Auto-conversion of keyword arguments, status?

**URL:** <https://discourse.julialang.org/t/auto-conversion-of-keyword-arguments-status/26350>\
**Category:** Internals & Design\
**Created:** [July 14, 2019, 4:10pm UTC](https://discourse.julialang.org/t/auto-conversion-of-keyword-arguments-status/26350 "2019-07-14T16:10:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [July 14, 2019, 4:10pm UTC](https://discourse.julialang.org/t/auto-conversion-of-keyword-arguments-status/26350/1 "2019-07-14T16:10:33Z")

</div>

I know there have been some discussions (and issues) about this in the past, but I’m curious what the current position on “auto-conversions for keyword arguments” is.

Is that something that will/could be added in future Julia versions? This would make it easier to write type-safe functions that have keyword arguments - e.g. one would declare the function with `arg::Int = 42` instead of `arg::Integer = 42`.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 14, 2019, 4:20pm UTC](https://discourse.julialang.org/t/auto-conversion-of-keyword-arguments-status/26350/2 "2019-07-14T16:20:50Z")

</div>

Could you give some example when the type stability is a problem? Just trying something naively doesn’t show it:

```julia
julia> @noinline f(;x::Integer=3) = x
f (generic function with 1 method)

julia> g(x) = f(;x=x) + f(;x=x)
g (generic function with 2 methods)

julia> @code_warntype g(3)
Body::Int64
1 ── %1 = Main.f::Core.Compiler.Const(f, false)
│ %2 = (Base.sle_int)(1, 1)::Bool
└─── goto #3 if not %2
2 ── %4 = (Base.sle_int)(1, 0)::Bool
└─── goto #4
3 ── nothing
4 ┄─ %7 = φ (#2 => %4, #3 => false)::Bool
└─── goto #6 if not %7
5 ── invoke Base.getindex(()::Tuple, 1::Int64)
└─── $(Expr(:unreachable))
6 ┄─ goto #7
7 ── goto #8
8 ── goto #9
9 ── goto #10
10 ─ %15 = invoke Main.:(#f#12)(_2::Int64, %1::Function)::Int64
└─── goto #11
11 ─ %17 = Main.f::Core.Compiler.Const(f, false)
│ %18 = (Base.sle_int)(1, 1)::Bool
└─── goto #13 if not %18
12 ─ %20 = (Base.sle_int)(1, 0)::Bool
└─── goto #14
13 ─ nothing
14 ┄ %23 = φ (#12 => %20, #13 => false)::Bool
└─── goto #16 if not %23
15 ─ invoke Base.getindex(()::Tuple, 1::Int64)
└─── $(Expr(:unreachable))
16 ┄ goto #17
17 ─ goto #18
18 ─ goto #19
19 ─ goto #20
20 ─ %31 = invoke Main.:(#f#12)(_2::Int64, %17::Function)::Int64
└─── goto #21
21 ─ %33 = (Base.add_int)(%15, %31)::Int64
└─── return %33

```

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [July 15, 2019, 4:25am UTC](https://discourse.julialang.org/t/auto-conversion-of-keyword-arguments-status/26350/3 "2019-07-15T04:25:06Z")

</div>

My bad - I think I was stuck in v0.6 times here, mentally. This used not to be type stable, and I always meant to ask about it, but now it seems to be. So while we don’t dispatch on keyword arguments, code generation does generate different code for different kwarg types now? Sorry, wasn’t aware of this!
