Inconsistency in TypeError message?

I like the second error because it’s clear to me that which keyword argument was passed with wrong type…

julia> function foo(a, b; x::Bool = true, y::String = "abc")
           println("hello")
           x ? a + b : y
       end

julia> foo(1,2; x = 1)
ERROR: TypeError: non-boolean (Int64) used in boolean context
Stacktrace:
 [1] (::var"#kw##foo")(::NamedTuple{(:x,),Tuple{Int64}}, ::typeof(foo), ::Int64, ::Int64) at ./none:0
 [2] top-level scope at REPL[16]:1

julia> foo(1,2; y = 2)
ERROR: TypeError: in keyword argument y, expected String, got Int64
Stacktrace:
 [1] (::var"#kw##foo")(::NamedTuple{(:y,),Tuple{Int64}}, ::typeof(foo), ::Int64, ::Int64) at ./none:0
 [2] top-level scope at REPL[17]:1
1 Like