Consider the following test function:

```
julia> test_default(x::T, y::R=Base.rtoldefault(R)) where {R<:Real,T<:Union{R,Complex{R}}} = (R, T)
test_default (generic function with 2 methods)
```

When a single complex number `x`

is given, this function returns the type `R`

of the real part of `x`

and the complex type `T`

of `x`

:

```
julia> test_default(1im)
(Int64, Complex{Int64})
julia> test_default(1.0im)
(Float64, Complex{Float64})
```

However, if we make the second argument `y`

a keyword argument, the function cannot be defined:

```
julia> test_default_kw(x::T; y::R=Base.rtoldefault(R)) where {R<:Real,T<:Union{R,Complex{R}}} = (R, T)
ERROR: UndefVarError: R not defined
```

Is this a bug, or there is a reason for this error?

Edit: here is a simpler breaking example:

```
julia> test_default_kw2(x::T; y::R=0) where {R<:Real,T<:Union{R,Complex{R}}} = (R, T)
ERROR: UndefVarError: R not defined
```