Skip to content

Commit

Permalink
Positional arguments may not come after keyword arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
angelcaru committed Jun 1, 2024
1 parent 1098422 commit 8faf837
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,14 @@ def call(self) -> ParseResult[Node]:
return res
assert pair is not None
kw, val = pair
if kw is None:
if kw is None and len(kwarg_nodes) == 0:
arg_nodes.append(val)
elif kw is None:
return res.failure(
InvalidSyntaxError(
val.pos_start, val.pos_end, "Positional arguments may not come after keyword arguments"
)
)
else:
kwarg_nodes[kw] = val

Expand Down
2 changes: 1 addition & 1 deletion tests/va_bug.rn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fun f(...args, kw=null) -> print(kw)

f(1, 2, 3)
f(1, 2, 3, kw=4, 5, 6)
f(1, 2, 3, kw=4)

0 comments on commit 8faf837

Please sign in to comment.