From: Judah Caruso Date: Thu, 7 Dec 2023 19:03:52 +0000 (-0700) Subject: improve non-const array size error X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=aaad9f696af2aa0fcaace2db89bff432464c7ea1;p=onyx.git improve non-const array size error --- diff --git a/compiler/src/types.c b/compiler/src/types.c index 7aceffb4..ee17680a 100644 --- a/compiler/src/types.c +++ b/compiler/src/types.c @@ -382,8 +382,14 @@ static Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b count = get_expression_integer_value(a_node->count_expr, &valid); if (!valid) { - onyx_report_error(a_node->token->pos, Error_Critical, "Array type size expression must be 'i32', got '%s'.", - type_get_name(a_node->count_expr->type)); + if (!(a_node->count_expr->flags & Ast_Flag_Const)) { + onyx_report_error(a_node->token->pos, Error_Critical, "Array type size must be a constant expression."); + } + else { + onyx_report_error(a_node->token->pos, Error_Critical, "Array type size expression must be 'i32', got '%s'.", + type_get_name(a_node->count_expr->type)); + } + return NULL; }