Skip to content

Commit d3276e1

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 2544e9f commit d3276e1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/julia-syntax.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@
555555
name positional-sparams
556556
`((|::|
557557
;; if there are optional positional args, we need to be able to reference the function name
558-
,(if (any kwarg? pargl) (gensy) UNUSED)
558+
,(if (any kwarg? `(,@pargl ,@vararg)) (gensy) UNUSED)
559559
(call (core kwftype) ,ftype)) ,kwdecl ,@pargl ,@vararg)
560560
`(block
561561
;; propagate method metadata to keyword sorter

test/keywordargs.jl

+6
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,9 @@ let m = first(methods(Core.kwcall, (NamedTuple,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)