Skip to content

Commit

Permalink
Expand kwcall lowering positional default check to vararg
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Keno committed Jul 14, 2023
1 parent ae08077 commit c272236
Show file tree
Hide file tree
Showing 2 changed files with 7 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 @@ -555,7 +555,7 @@
name positional-sparams
`((|::|
;; if there are optional positional args, we need to be able to reference the function name
,(if (any kwarg? pargl) (gensy) UNUSED)
,(if (any kwarg? `(,@pargl ,@vararg)) (gensy) UNUSED)
(call (core kwftype) ,ftype)) ,kwdecl ,@pargl ,@vararg)
`(block
;; propagate method metadata to keyword sorter
Expand Down
6 changes: 6 additions & 0 deletions test/keywordargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,9 @@ let m = first(methods(Core.kwcall, (NamedTuple,typeof(kwf1),Vararg)))
@test Core.kwcall(1) == "hi 1"
@test which(Core.kwcall, (Int,)).name === :kwcall
end

# issue #50518
function f50518(xs...=["a", "b", "c"]...; debug=false)
return xs[1]
end
@test f50518() == f50518(;debug=false) == "a"

0 comments on commit c272236

Please sign in to comment.