fix: P1审查修复 — error.c arena化 + Self类型解析 + trait查找加固 + 缓冲区安全
P1-①: error_init/add 从 malloc/realloc/strdup 改为 arena_alloc/arena_strdup P1-②: impl 方法中 Self 类型在 sema 解析为实际结构体名 P1-③: trait 方法 fallback 增加前缀校验(strncmp),method_name 统一更新 P1-④: codegen args[16] 增加溢出检查,移除 parser 未使用的 mods/uses 数组 新增: 36_self_type.l 集成测试(Self 类型 + trait 方法) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -353,6 +353,7 @@ static LLVMValueRef codegen_expr(CgCtx* ctx, AstNode* node) {
|
||||
LLVMValueRef fn = find_fn(ctx, node->as.call.name);
|
||||
if (!fn) return NULL;
|
||||
LLVMValueRef args[16];
|
||||
if (node->as.call.arg_count > 16) { ctx->error = "函数参数过多(最多16)"; return NULL; }
|
||||
for (size_t i = 0; i < node->as.call.arg_count; i++) {
|
||||
args[i] = codegen_expr(ctx, node->as.call.args[i]);
|
||||
if (!args[i]) return NULL;
|
||||
@@ -440,6 +441,7 @@ static LLVMValueRef codegen_expr(CgCtx* ctx, AstNode* node) {
|
||||
LLVMValueRef fn = find_fn(ctx, mangled);
|
||||
if (!fn) return NULL;
|
||||
// 参数列表: [receiver, 用户参数...]
|
||||
if (node->as.method_call.arg_count + 1 > 16) { ctx->error = "方法参数过多(最多15)"; return NULL; }
|
||||
LLVMValueRef args[16];
|
||||
args[0] = codegen_expr(ctx, node->as.method_call.receiver);
|
||||
if (!args[0]) return NULL;
|
||||
|
||||
Reference in New Issue
Block a user