Skip to content

Commit 73a1031

Browse files
committed
Partially fix #9
1 parent 704a91e commit 73a1031

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Manifest.toml

src/KeywordDispatch.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ argtype(x::Expr) = x.head == :(::) ? x.args[end] : error("unexpected expression
5454
function unwrap_where(expr)
5555
stack = Any[]
5656
while expr isa Expr && expr.head == :where
57-
push!(stack, expr.args[2])
57+
append!(stack, expr.args[2:end])
5858
expr = expr.args[1]
5959
end
6060
expr, stack

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,15 @@ end
251251

252252
@test f(alpha=0,beta=0) == 3
253253
end
254+
255+
@testset "multiple where clauses" begin
256+
# based on https://github.com/simonbyrne/KeywordDispatch.jl/issues/9
257+
@kwdispatch f(x::T) where {T}
258+
259+
@kwmethod f(x::T; y::TI) where {T, TI <: Vector{T}} = y
260+
261+
@test f(1.0,y=[1.0,2.0]) == [1.0,2.0]
262+
@test f(1,y=[1,2]) == [1,2]
263+
264+
@test_throws KeywordMethodError f(1,y=[1.0,2.0])
265+
end

0 commit comments

Comments
 (0)