mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
Allow named arguments variadic expansion ..
This commit is contained in:
+8
-2
@@ -2752,9 +2752,9 @@ gb_internal Ast *parse_call_expr(AstFile *f, Ast *operand) {
|
|||||||
|
|
||||||
open_paren = expect_token(f, Token_OpenParen);
|
open_paren = expect_token(f, Token_OpenParen);
|
||||||
|
|
||||||
|
bool seen_ellipsis = false;
|
||||||
while (f->curr_token.kind != Token_CloseParen &&
|
while (f->curr_token.kind != Token_CloseParen &&
|
||||||
f->curr_token.kind != Token_EOF &&
|
f->curr_token.kind != Token_EOF) {
|
||||||
ellipsis.pos.line == 0) {
|
|
||||||
if (f->curr_token.kind == Token_Comma) {
|
if (f->curr_token.kind == Token_Comma) {
|
||||||
syntax_error(f->curr_token, "Expected an expression not ,");
|
syntax_error(f->curr_token, "Expected an expression not ,");
|
||||||
} else if (f->curr_token.kind == Token_Eq) {
|
} 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);
|
Ast *value = parse_value(f);
|
||||||
arg = ast_field_value(f, arg, value, eq);
|
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);
|
array_add(&args, arg);
|
||||||
|
|
||||||
|
if (ellipsis.pos.line != 0) {
|
||||||
|
seen_ellipsis = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!allow_field_separator(f)) {
|
if (!allow_field_separator(f)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user