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
+8 -2
View File
@@ -2454,10 +2454,16 @@ gb_internal i64 check_array_count(CheckerContext *ctx, Operand *o, Ast *e) {
if (e == nullptr) { if (e == nullptr) {
return 0; return 0;
} }
if (e->kind == Ast_UnaryExpr && if (e->kind == Ast_UnaryExpr) {
e->UnaryExpr.op.kind == Token_Question) { Token op = e->UnaryExpr.op;
if (op.kind == Token_Question) {
return -1; 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); check_expr_or_type(ctx, o, e);
if (o->mode == Addressing_Type) { if (o->mode == Addressing_Type) {