# Extending function with new keyword argument fails

**URL:** <https://discourse.julialang.org/t/extending-function-with-new-keyword-argument-fails/36770>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 31, 2020, 12:45am UTC](https://discourse.julialang.org/t/extending-function-with-new-keyword-argument-fails/36770 "2020-03-31T00:45:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SEA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sea/32/8956_2.png) [@SEA](https://discourse.julialang.org/u/SEA)\
**Post date:** [March 31, 2020, 12:45am UTC](https://discourse.julialang.org/t/extending-function-with-new-keyword-argument-fails/36770/1 "2020-03-31T00:45:26Z")

</div>

I ran into this problem while trying to extend stdlib’s `cholesky` with a new keyword argument. This is a minimal example.

```julia
import LinearAlgebra: cholesky
struct T end
cholesky(A::AbstractMatrix, ::Val{false} = Val(false); b::T) = println(b)
A = randn(3, 3)
cholesky(A, Val(false); b = T()) # fails to run this method

```

The method fails to run, even though Julia lists it as a possible candidate in the stack trace without any associated error. I got the same error on both 1.3.1 and 1.4. What is going wrong here?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 31, 2020, 8:39am UTC](https://discourse.julialang.org/t/extending-function-with-new-keyword-argument-fails/36770/2 "2020-03-31T08:39:19Z")

</div>

The method

```julia
cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
    ::Val{false}=Val(false); check::Bool = true)

```

defined in `LinearAlgebra` is more specific so it is run instead (keyword arguments do not participate in dispatch).

---

<div class="post-metadata">

**Author:** ![SEA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sea/32/8956_2.png) [@SEA](https://discourse.julialang.org/u/SEA)\
**Post date:** [March 31, 2020, 3:04pm UTC](https://discourse.julialang.org/t/extending-function-with-new-keyword-argument-fails/36770/3 "2020-03-31T15:04:39Z")

</div>

Thank you for your answer! I didn’t know keyword arguments don’t participate in dispatch. For posterity, here is the relevant excerpt in the docs (in the Methods section)

> Keyword arguments behave quite differently from ordinary positional arguments. In particular, they do not participate in method dispatch. Methods are dispatched based only on positional arguments, with keyword arguments processed after the matching method is identified.
