aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-06-29 10:13:15 +0100
committergingerBill <bill@gingerbill.org>2024-06-29 10:13:15 +0100
commit906afa41544c692f65467f1dba546a6ca4e71f1d (patch)
tree41f1e903a636c4e9a839e88e50fa513c4c2962a1
parent06652bebce111640930a513c825e59f7b37bbd4f (diff)
Allow for `when x in y {` (minor oversight in syntax)
-rw-r--r--core/odin/parser/parser.odin5
-rw-r--r--src/parser.cpp3
2 files changed, 8 insertions, 0 deletions
diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin
index 03fb4d66d..715b96d84 100644
--- a/core/odin/parser/parser.odin
+++ b/core/odin/parser/parser.odin
@@ -689,7 +689,12 @@ parse_when_stmt :: proc(p: ^Parser) -> ^ast.When_Stmt {
prev_level := p.expr_level
p.expr_level = -1
+ prev_allow_in_expr := p.allow_in_expr
+ p.allow_in_expr = true
+
cond = parse_expr(p, false)
+
+ p.allow_in_expr = prev_allow_in_expr
p.expr_level = prev_level
if cond == nil {
diff --git a/src/parser.cpp b/src/parser.cpp
index 0e971f792..b1a179573 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -4573,9 +4573,12 @@ gb_internal Ast *parse_when_stmt(AstFile *f) {
isize prev_level = f->expr_level;
f->expr_level = -1;
+ bool prev_allow_in_expr = f->allow_in_expr;
+ f->allow_in_expr = true;
cond = parse_expr(f, false);
+ f->allow_in_expr = prev_allow_in_expr;
f->expr_level = prev_level;
if (cond == nullptr) {