diff options
| author | gingerBill <bill@gingerbill.org> | 2024-07-22 16:29:29 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-07-22 16:29:29 +0100 |
| commit | fcaa47986aa5477e60a67a4ace5c7b020b214afd (patch) | |
| tree | 79496157d862fa65947a2c8161c40944139df296 /src | |
| parent | ba3d7ba5d3fe22800d980dbb420be4fbb117be0c (diff) | |
Improve error handling for invalid syntax doing `[*]T`
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_type.cpp | 12 |
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); |