diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-07 11:42:48 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-07 11:42:48 +0100 |
| commit | 0da6a3e214c66e2955307e2aad12d844a051f8d8 (patch) | |
| tree | 4440453fe498dd2c4957a9bda42ddf38d9637637 /src/check_type.cpp | |
| parent | 05a17048982dea73ac0c7db1e743582abf73233b (diff) | |
Fix #3530
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 457375779..6efac54d6 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -797,11 +797,11 @@ gb_internal void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *nam enum_type->Enum.scope = ctx->scope; Type *base_type = t_int; - if (et->base_type != nullptr) { + if (unparen_expr(et->base_type) != nullptr) { base_type = check_type(ctx, et->base_type); } - if (base_type == nullptr || !is_type_integer(base_type)) { + if (base_type == nullptr || base_type == t_invalid || !is_type_integer(base_type)) { error(node, "Base type for enumeration must be an integer"); return; } @@ -3265,6 +3265,11 @@ gb_internal bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, T case_end; case_ast_node(pe, ParenExpr, e); + if (pe->expr == nullptr) { + error(e, "Expected an expression or type within the parentheses"); + *type = t_invalid; + return true; + } *type = check_type_expr(ctx, pe->expr, named_type); set_base_type(named_type, *type); return true; |