Skip to content

Commit

Permalink
Fix Vararg interaction with keyword function lowering,Fix #13919 and #…
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoegh committed Jul 28, 2016
1 parent e717ded commit 19c652b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
(ftype (decl-type (car pargl)))
;; 1-element list of vararg argument, or empty if none
(vararg (let ((l (if (null? pargl) '() (last pargl))))
(if (vararg? l)
(if (or (vararg? l) (varargexpr? l))
(list l) '())))
;; positional args without vararg
(pargl (if (null? vararg) pargl (butlast pargl)))
Expand Down
7 changes: 7 additions & 0 deletions test/keywordargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ kwf2(x, rest...; y=1) = (x, y, rest)
@test_throws MethodError kwf2(0, z=1)
@test_throws MethodError kwf2(y=1)

# Test for #13919
test13919(x::Vararg{Int}; key=100) = (x, key)
@test test13919(1, 1)[1] === (1, 1)
@test test13919(1, 1)[2] === 100
@test test13919(1, 1, key=10)[1] === (1, 1)
@test test13919(1, 1, key=10)[2] === 10

# keyword arg with declared type
kwf3(x; y::Float64 = 1.0) = x + y
@test kwf3(2) == 3.0
Expand Down

0 comments on commit 19c652b

Please sign in to comment.