diff options
| author | hchac <dev@hchac.com> | 2023-07-13 15:28:36 -0400 |
|---|---|---|
| committer | hchac <dev@hchac.com> | 2023-07-13 15:38:10 -0400 |
| commit | cb5c8219898445a5501a95107c0200ea68b89a39 (patch) | |
| tree | 81a041d3289882b2f0782a19b92cdda3f9a3669e | |
| parent | 204c0fa4d87b6c7b995ba60b17a61f832f67cc49 (diff) | |
Matching C++ parser changes from commit 67ca9166d36375fd42725c16ca3933d4c91ebfee.
Without these changes the core library parser fails to parse:
- core/fmt/fmt.odin:
Line 126 (and others):
sbprint(&str, ..args, sep=sep)
- core/fmt/fmt_os.odin:
Line 17 (and others):
return wprint(w, ..args, sep=sep)
- core/log/log.odin:
Line 79 (and others):
logf(.Debug, fmt_str, ..args, location=location)
- core/runtime/core_builtin.odin:
Line 475 (and others):
return append_elems(array, ..args, loc=loc)
| -rw-r--r-- | core/odin/parser/parser.odin | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 15a33d86b..31ab7674e 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -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 } |