aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-07-22 16:29:29 +0100
committergingerBill <bill@gingerbill.org>2024-07-22 16:29:29 +0100
commitfcaa47986aa5477e60a67a4ace5c7b020b214afd (patch)
tree79496157d862fa65947a2c8161c40944139df296 /src/check_type.cpp
parentba3d7ba5d3fe22800d980dbb420be4fbb117be0c (diff)
Improve error handling for invalid syntax doing `[*]T`
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index e3609970a..22b77db3c 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -2454,9 +2454,15 @@ gb_internal i64 check_array_count(CheckerContext *ctx, Operand *o, Ast *e) {
if (e == nullptr) {
return 0;
}
- if (e->kind == Ast_UnaryExpr &&
- e->UnaryExpr.op.kind == Token_Question) {
- return -1;
+ if (e->kind == Ast_UnaryExpr) {
+ Token op = e->UnaryExpr.op;
+ if (op.kind == Token_Question) {
+ return -1;
+ }
+ if (e->UnaryExpr.expr == nullptr) {
+ error(op, "Invalid array count '[%.*s]'", LIT(op.string));
+ return 0;
+ }
}
check_expr_or_type(ctx, o, e);