Signed-off-by: Sebastian <sebastian@sebsite.pw>
---
hare/parse/+test/expr.ha | 3 +++
hare/parse/expr.ha | 10 +++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/hare/parse/+test/expr.ha b/hare/parse/+test/expr.ha
index db41f3f5..0b2a17a1 100644
--- a/hare/parse/+test/expr.ha
+++ b/hare/parse/+test/expr.ha
@@ -191,6 +191,9 @@
for (let x = 10; x < 10; x) {
x;
};
+ for (static let x = 0; x < 10) {
+ x;
+ };
};
");
};
diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha
index b3d80e98..295c360a 100644
--- a/hare/parse/expr.ha
+++ b/hare/parse/expr.ha
@@ -637,11 +637,15 @@ fn for_expr(lexer: *lex::lexer) (ast::expr | error) = {
want(lexer, ltok::LPAREN)?;
const bindings: nullable *ast::expr =
- match (peek(lexer, ltok::LET, ltok::CONST)?) {
+ match (peek(lexer, ltok::LET, ltok::CONST, ltok::STATIC)?) {
case void =>
yield null;
- case lex::token =>
- const bindings = alloc(binding(lexer, false)?);
+ case let tok: lex::token =>
+ let is_static = if (tok.0 == ltok::STATIC) {
+ want(lexer, ltok::STATIC)?;
+ yield true;
+ } else false;
+ const bindings = alloc(binding(lexer, is_static)?);
want(lexer, ltok::SEMICOLON)?;
yield bindings;
};
--
2.35.1