hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 4afcd76b8983a14ada118d14952c56f5cf99077f
parent 805b5df0492515aae3d2d2ef685edde403e27f75
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu,  5 Jan 2023 18:03:04 -0500

hare::parse: add missing error propagation

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mhare/parse/expr.ha | 8++++----
Mhare/parse/type.ha | 6+++---
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha @@ -690,7 +690,7 @@ fn for_expr(lexer: *lex::lexer) (ast::expr | error) = { }; const cond = alloc(expr(lexer)?); const afterthought: nullable *ast::expr = - match (peek(lexer, ltok::SEMICOLON)) { + match (peek(lexer, ltok::SEMICOLON)?) { case void => yield null; case lex::token => @@ -917,7 +917,7 @@ fn plain_struct( switch (want(lexer, ltok::COMMA, ltok::RBRACE)?.0) { case ltok::RBRACE => break; case ltok::COMMA => - if (try(lexer, ltok::RBRACE) is lex::token) { + if (try(lexer, ltok::RBRACE)? is lex::token) { break; }; }; @@ -1016,7 +1016,7 @@ fn postfix(lexer: *lex::lexer, lvalue: (ast::expr | void)) (ast::expr | error) = }; let tok = match (try(lexer, ltok::LPAREN, ltok::DOT, - ltok::LBRACKET, ltok::QUESTION, ltok::LNOT)) { + ltok::LBRACKET, ltok::QUESTION, ltok::LNOT)?) { case void => return lvalue; case let tok: lex::token => @@ -1222,7 +1222,7 @@ fn unarithm(lexer: *lex::lexer) (ast::expr | error) = { const tok = match (try(lexer, ltok::PLUS, ltok::MINUS, ltok::BNOT, ltok::LNOT, ltok::TIMES, ltok::BAND, - ltok::SWITCH, ltok::MATCH, ltok::COLON, ltok::LBRACE)) { + ltok::SWITCH, ltok::MATCH, ltok::COLON, ltok::LBRACE)?) { case void => return builtin(lexer); case let tok: lex::token => diff --git a/hare/parse/type.ha b/hare/parse/type.ha @@ -245,7 +245,7 @@ fn struct_union_type(lexer: *lex::lexer) (ast::_type | error) = { want(lexer, ltok::LBRACE)?; for (true) { - if (try(lexer, ltok::RBRACE) is lex::token) { + if (try(lexer, ltok::RBRACE)? is lex::token) { synassert(lex::mkloc(lexer), len(membs) != 0, "Expected field list")?; break; @@ -406,7 +406,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { let membs: []ast::enum_field = []; for (true) { - if (try(lexer, ltok::RBRACE) is lex::token) { + if (try(lexer, ltok::RBRACE)? is lex::token) { synassert(lex::mkloc(lexer), len(membs) != 0, "Expected member list")?; break; @@ -416,7 +416,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { let name = want(lexer, ltok::NAME)?; let comment = strings::dup(lex::comment(lexer)); let value: nullable *ast::expr = - if (try(lexer, ltok::EQUAL) is lex::token) + if (try(lexer, ltok::EQUAL)? is lex::token) alloc(expr(lexer)?) else null;