aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2023-06-23 12:11:46 +0100
committerGitHub <noreply@github.com>2023-06-23 12:11:46 +0100
commit9841b11a5423e2cba67c19fbd06e28732d36109c (patch)
tree7c067cbc1501c4a044a80944ca282dd7da974074 /src/parser.cpp
parent5a6d5374d780e726be82f3576b4f647d9096d012 (diff)
parentc48057081e451c81524c7727ec3ccf434a45726f (diff)
Merge pull request #2597 from odin-lang/ordered-named-arguments
Allowing for Positional and Named Arguments in Procedure Calls
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 883342b21..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,11 +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;
}