Merge pull request #2696 from hwchen/hwchen/fix-parse-call-expr-ellipses

core:odin/parser allow args after varargs in parse_call_expr
This commit is contained in:
gingerBill
2023-08-05 17:07:28 +01:00
committed by GitHub
2 changed files with 30 additions and 2 deletions
+8 -2
View File
@@ -2941,9 +2941,9 @@ parse_call_expr :: proc(p: ^Parser, operand: ^ast.Expr) -> ^ast.Expr {
p.expr_level += 1
open := expect_token(p, .Open_Paren)
seen_ellipsis := false
for p.curr_tok.kind != .Close_Paren &&
p.curr_tok.kind != .EOF &&
ellipsis.pos.line == 0 {
p.curr_tok.kind != .EOF {
if p.curr_tok.kind == .Comma {
error(p, p.curr_tok.pos, "expected an expression not ,")
@@ -2972,10 +2972,16 @@ parse_call_expr :: proc(p: ^Parser, operand: ^ast.Expr) -> ^ast.Expr {
fv.value = value
arg = fv
} else if seen_ellipsis {
error(p, arg.pos, "Positional arguments are not allowed after '..'")
}
append(&args, arg)
if ellipsis.pos.line != 0 {
seen_ellipsis = true
}
if !allow_token(p, .Comma) {
break
}