aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-10-01 11:55:46 +0200
committerHimbeer <himbeer@disroot.org>2024-10-01 13:51:46 +0200
commit91c0da3a8bea23d3729ecc02b599774a62f9230c (patch)
tree123278b724713f1b1a431ca52f7981fd539fc59d
parente8c3ca08b84e2a462ed461009a5b63cb65e9288f (diff)
Fix invalid inner types not raising an error
-rw-r--r--src/parse.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/parse.c b/src/parse.c
index 4b938bb..a294898 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -983,15 +983,27 @@ parse_type(struct lexer *lexer, struct type *out)
case T_STAR:
out->kind = TYP_POINTER;
out->desc.inner = must_malloc(sizeof(struct type));
- return parse_type(lexer, out->desc.inner);
+
+ if (!parse_type(lexer, out->desc.inner)) {
+ error(lex_loc(lexer), "syntax error: expected type");
+ }
+ return true;
case T_QUESTION:
out->kind = TYP_OPTIONAL;
out->desc.inner = must_malloc(sizeof(struct type));
- return parse_type(lexer, out->desc.inner);
+
+ if (!parse_type(lexer, out->desc.inner)) {
+ error(lex_loc(lexer), "syntax error: expected type");
+ }
+ return true;
case T_BANG:
out->kind = TYP_FALLIBLE;
out->desc.inner = must_malloc(sizeof(struct type));
- return parse_type(lexer, out->desc.inner);
+
+ if (!parse_type(lexer, out->desc.inner)) {
+ error(lex_loc(lexer), "syntax error: expected type");
+ }
+ return true;
case T_BOOL:
out->kind = TYP_BOOL;
return true;