From 13f80915c722744b3a425af303550df60505bc1d Mon Sep 17 00:00:00 2001 From: cozis Date: Wed, 6 Apr 2022 13:40:55 +0200 Subject: [PATCH] bug fix --- examples/bug2.noja | 2 ++ examples/return.noja | 7 ++++--- src/compiler/parse.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 examples/bug2.noja diff --git a/examples/bug2.noja b/examples/bug2.noja new file mode 100644 index 0000000..8dffb40 --- /dev/null +++ b/examples/bug2.noja @@ -0,0 +1,2 @@ +fun f() return 1, 2; +print((a, b) = f(), '\n'); \ No newline at end of file diff --git a/examples/return.noja b/examples/return.noja index 9305d3d..1e97864 100644 --- a/examples/return.noja +++ b/examples/return.noja @@ -1,8 +1,9 @@ fun hello() - return 1, "hello"; + return [1, 2, 3], "hello"; -a, b = hello(); +print((a, b, c) = hello(), '\n'); print('a = ', a, '\n'); -print('b = ', b, '\n'); \ No newline at end of file +print('b = ', b, '\n'); +print('c = ', c, '\n'); \ No newline at end of file diff --git a/src/compiler/parse.c b/src/compiler/parse.c index 16034ec..01e87d9 100644 --- a/src/compiler/parse.c +++ b/src/compiler/parse.c @@ -1637,6 +1637,9 @@ static Node *parse_expression_2(Context *ctx, Node *left_expr, int min_prec, _Bo if(right_expr == NULL) return NULL; + + if(ctx->token->kind == ',' && allow_toplev_tuples == 0) + break; } OperExprNode *temp;