Skip to content

Commit 0c9c477

Browse files
KenoKristofferC
authored andcommitted
Expand kwcall lowering positional default check to vararg
Fixes the case from #50518, but we actually have two test cases in the tests that also hit this (e.g. this one: ``` f40964(xs::Int...=1; k = 2) = (xs, k) ```), but just happened not to hit the bad codegen path. #50556, once merged would have complained on those definitions as well, without this fix. (cherry picked from commit c272236)
1 parent e2208a7 commit 0c9c477

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/julia-syntax.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@
559559
name positional-sparams
560560
`((|::|
561561
;; if there are optional positional args, we need to be able to reference the function name
562-
,(if (any kwarg? pargl) (gensy) UNUSED)
562+
,(if (any kwarg? `(,@pargl ,@vararg)) (gensy) UNUSED)
563563
(call (core kwftype) ,ftype)) ,kw ,@pargl ,@vararg)
564564
`(block
565565
;; propagate method metadata to keyword sorter

test/keywordargs.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,9 @@ let m = first(methods(Core.kwcall, (Any,typeof(kwf1),Vararg)))
394394
@test Core.kwcall(1) == "hi 1"
395395
@test which(Core.kwcall, (Int,)).name === :kwcall
396396
end
397+
398+
# issue #50518
399+
function f50518(xs...=["a", "b", "c"]...; debug=false)
400+
return xs[1]
401+
end
402+
@test f50518() == f50518(;debug=false) == "a"

0 commit comments

Comments
 (0)