hare

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

commit 7accd27b5e487cd323d30b08916e87274b6efb02
parent 4814319f396422153ca233df48f37be488eea106
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sat, 29 Jul 2023 20:35:26 -0400

hare::parse: fix abort in name_list

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

Diffstat:
Mhare/parse/+test/unit_test.ha | 6++++++
Mhare/parse/import.ha | 2+-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hare/parse/+test/unit_test.ha b/hare/parse/+test/unit_test.ha @@ -114,6 +114,12 @@ fn tup_to_import(tup: import_tuple) ast::import = ast::import { let tok = lex::lex(&lexer) as lex::token; assert(tok.0 == lex::ltok::EXPORT); + + const in = "use a::{b = c = d};\n"; + let buf = bufio::fixed(strings::toutf8(in), mode::READ); + let lexer = lex::init(&buf, "<test>"); + defer lex::finish(&lexer); + assert(imports(&lexer) is error); }; @test fn decls() void = { diff --git a/hare/parse/import.ha b/hare/parse/import.ha @@ -19,7 +19,7 @@ fn name_list(lexer: *lex::lexer) ([]((str | void), str) | error) = { name.1 = want(lexer, ltok::NAME)?.1 as str; }; - switch (want(lexer, ltok::EQUAL, ltok::COMMA, ltok::RBRACE)?.0) { + switch (want(lexer, ltok::COMMA, ltok::RBRACE)?.0) { case ltok::COMMA => match (try(lexer, ltok::RBRACE)?) { case void => void;