summaryrefslogtreecommitdiff
path: root/src/parser/parser_stmt.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-20 12:51:23 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-20 12:51:23 +0000
commitb106fe19b55e9fe3348b3a5c9992c21dac27b02c (patch)
tree32663c9a791b7f45ce9bc61c5a87351d5dc2c782 /src/parser/parser_stmt.c
parente5d8c4219cfe5629a3ce4dbff01406a1817a788f (diff)
Working a bit on the LSP + fixed some bugs
Diffstat (limited to 'src/parser/parser_stmt.c')
-rw-r--r--src/parser/parser_stmt.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/parser/parser_stmt.c b/src/parser/parser_stmt.c
index 7433525..c5efe8a 100644
--- a/src/parser/parser_stmt.c
+++ b/src/parser/parser_stmt.c
@@ -335,6 +335,14 @@ ASTNode *parse_match(ParserContext *ctx, Lexer *l)
zpanic_at(lexer_peek(l), "Expected =>");
}
+ // Create scope for the case to hold the binding
+ enter_scope(ctx);
+ if (binding)
+ {
+ // If ref binding, mark as pointer type so auto-deref (->) works
+ add_symbol(ctx, binding, is_ref ? "void*" : "unknown", NULL);
+ }
+
ASTNode *body;
Token pk = lexer_peek(l);
if (pk.type == TOK_LBRACE)
@@ -355,6 +363,8 @@ ASTNode *parse_match(ParserContext *ctx, Lexer *l)
body = parse_expression(ctx, l);
}
+ exit_scope(ctx);
+
ASTNode *c = ast_create(NODE_MATCH_CASE);
c->match_case.pattern = pattern;
c->match_case.binding_name = binding;