fix: AST_PARAMETER 增加数组元素类型字段 + 五子棋集成测试
问题: 函数参数声明 i64[N] 只在 TypeInfo 存储数组信息, AST_PARAMETER 仅存 TypeKind(TYPE_ARRAY), 丢失元素类型和大小, 导致 sema 将参数 数组误判为 i32[N], codegen 生成 void GEP 而崩溃。 修复: - AST_PARAMETER 新增 arr_elem_type/arr_elem_struct/arr_size 字段 - parser 传入 parse_type_expr 的完整数组信息 - sema 将数组信息从 AST 节点复制到 Symbol - codegen 为数组参数生成正确的 LLVMArrayType 附加: 45_gomoku.l — 5x5 五子棋双AI对弈, 测试数组/函数/循环/字符串 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -76,7 +76,8 @@ struct AstNode {
|
||||
TypeKind* multi_ret_types; const char** multi_ret_snames; size_t multi_ret_count;
|
||||
const char** captured; TypeKind* cap_types; size_t cap_count; } function;
|
||||
// AST_PARAMETER (也用作结构体字段: name + type)
|
||||
struct { const char* name; TypeKind type; const char* struct_type_name; bool is_out; } parameter;
|
||||
struct { const char* name; TypeKind type; const char* struct_type_name; bool is_out;
|
||||
TypeKind arr_elem_type; const char* arr_elem_struct; int64_t arr_size; } parameter;
|
||||
// AST_BLOCK
|
||||
struct { struct AstNode** stmts; size_t stmt_count; } block;
|
||||
// AST_LET_STMT
|
||||
@@ -158,7 +159,8 @@ AstNode* ast_make_function(void* alloc, const char* name, AstNode** params, size
|
||||
TypeKind ret, const char* ret_struct_name, AstNode* body,
|
||||
bool is_pub, const char** type_params, size_t tp_count,
|
||||
SourceLoc loc);
|
||||
AstNode* ast_make_parameter(void* alloc, const char* name, TypeKind type, const char* struct_type_name, bool is_out, SourceLoc loc);
|
||||
AstNode* ast_make_parameter(void* alloc, const char* name, TypeKind type, const char* struct_type_name, bool is_out,
|
||||
TypeKind arr_elem, const char* arr_elem_sname, int64_t arr_size, SourceLoc loc);
|
||||
AstNode* ast_make_block(void* alloc, AstNode** stmts, size_t count, SourceLoc loc);
|
||||
AstNode* ast_make_let(void* alloc, const char* name, TypeKind annot_type, bool has_type_annot,
|
||||
bool is_mut, AstNode* init, const char* struct_type_name,
|
||||
|
||||
Reference in New Issue
Block a user