commit f173d66f5761b20ea71688caf5f3f2e66cce88dd
parent 7c25166f2e4ec72ab37696dd0ed21da6133cbde7
Author: Alexey Yerin <yyp@disroot.org>
Date: Tue, 31 Oct 2023 21:18:59 +0300
hare::parse: Disallow single element tuple types
Signed-off-by: Alexey Yerin <yyp@disroot.org>
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hare/parse/type.ha b/hare/parse/type.ha
@@ -209,9 +209,15 @@ fn tuple_type(
) (ast::_type | error) = {
let tuple: ast::tuple_type = [];
append(tuple, alloc(first));
- for (try(lexer, ltok::RPAREN)? is void) {
+ for (true) {
append(tuple, alloc(_type(lexer)?));
- if (try(lexer, ltok::COMMA)? is void) {
+ match (try(lexer, ltok::COMMA)?) {
+ case lex::token =>
+ match (try(lexer, ltok::RPAREN)) {
+ case lex::token => break;
+ case => void;
+ };
+ case void =>
want(lexer, ltok::RPAREN)?;
break;
};