Improve error handling for invalid syntax doing [*]T

This commit is contained in:
gingerBill
2024-07-22 16:29:29 +01:00
parent ba3d7ba5d3
commit fcaa47986a

View File

@@ -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);