aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-06-21 01:03:21 +0100
committergingerBill <bill@gingerbill.org>2023-06-21 01:03:21 +0100
commit67ca9166d36375fd42725c16ca3933d4c91ebfee (patch)
tree6da3c4d2fca91a62a5626dc805a4c4596317e8e4 /src/parser.cpp
parentb2ced834ba01c61c8ec842af2de5f480d1e93462 (diff)
Allow named arguments variadic expansion `..`
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 96b7c96ea..b756412ff 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2752,9 +2752,9 @@ gb_internal Ast *parse_call_expr(AstFile *f, Ast *operand) {
open_paren = expect_token(f, Token_OpenParen);
+ bool seen_ellipsis = false;
while (f->curr_token.kind != Token_CloseParen &&
- f->curr_token.kind != Token_EOF &&
- ellipsis.pos.line == 0) {
+ f->curr_token.kind != Token_EOF) {
if (f->curr_token.kind == Token_Comma) {
syntax_error(f->curr_token, "Expected an expression not ,");
} else if (f->curr_token.kind == Token_Eq) {
@@ -2777,9 +2777,15 @@ gb_internal Ast *parse_call_expr(AstFile *f, Ast *operand) {
Ast *value = parse_value(f);
arg = ast_field_value(f, arg, value, eq);
+ } else if (seen_ellipsis) {
+ syntax_error(arg, "Positional arguments are not allowed after '..'");
}
array_add(&args, arg);
+ if (ellipsis.pos.line != 0) {
+ seen_ellipsis = true;
+ }
+
if (!allow_field_separator(f)) {
break;
}