From 4df11f3c6f9a7835fc513ec27c85e7541c58e232 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 18 Dec 2024 19:29:39 +0800 Subject: [PATCH] support empty tuple `()` --- src/compiler/compiler.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 7ef73957..71bf9318 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -1722,6 +1722,11 @@ static Error* exprUnaryOp(Compiler* self) { static Error* exprGroup(Compiler* self) { Error* err; int line = prev()->line; + if(match(TK_RPAREN)) { + // empty tuple + Ctx__s_push(ctx(), (Expr*)TupleExpr__new(line, 0)); + return NULL; + } match_newlines(); check(EXPR_TUPLE(self)); // () is just for change precedence match_newlines();