From 99ddff2d87291c543448d29a99618ff8255bf3a8 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 29 Aug 2026 09:01:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(tpv):=20t.CArray/t.CPtr=20=E4=B8=8B?= =?UTF-8?q?=E6=A0=87=E5=85=83=E7=B4=A0=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=BF=94=E5=9B=9E=20None=20=E4=BA=A4?= =?UTF-8?q?=E5=A4=9A=E9=81=8D=E6=94=B6=E6=95=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 阶段2 删 map_t_type stdint 硬编码后,UINT 等 typedef 仅经 CTypedef 动态表解析;Phase 1a(declare_only=1)无 vpi 注入,依赖 typedef 的类(zhuff_code)被跳过,导致 t.CArray[zhuff_code, N] 元素解析被误 fatal 中断编译(zhuff.vp L19 根因)。与裸名 CArray 路径及 ClassGenDef 字段 pending 机制保持一致,真实类型错误由 Phase A 收敛检查暴露。 --- App/lib/core/Gen/Type/TypeGenResolve.vp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/App/lib/core/Gen/Type/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp index f52d7d7..f383532 100644 --- a/App/lib/core/Gen/Type/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -1805,7 +1805,15 @@ class TypeGenResolve(TypeGenBase.TypeGenBase): inner_cptr_ty: llvmlite.LLVMType | t.CPtr = self.resolve_annotation_type( pool, sub.slice, imported_modules, from_imports, trans, depth + 1) if inner_cptr_ty is None: - self.Gen.TypeGenErr.fatal_type_error(sub.slice, "t.CPtr[?] 元素类型解析失败") + # 元素类型依赖未就绪(如 t.CPtr[类] 中类尚未注册):返回 None + # 交上层多遍收敛,不在此 fatal 中断 Phase 1a 预注册。 + # 根因:阶段2 删 map_t_type stdint 硬编码后,UINT 等只经 CTypedef + # 动态表解析;Phase 1a(declare_only=1)无 vpi 注入 → 依赖 typedef + # 的类(zhuff_code)被跳过 → t.CArray[t.CPtr?]/t.CPtr[类] 元素 + # 解析失败被误 fatal(zhuff.vp 根因)。与裸名 CArray 路径(L1760) + # 及 ClassGenDef 字段 pending 机制保持一致;真实类型错误由 Phase A + # 收敛检查暴露("Phase A 无法完成翻译")。 + return None return llvmlite.Ptr(pool, inner_cptr_ty) if string.strcmp(arr_at.attr, "CArray") != 0: self.Gen.TypeGenErr.fatal_type_error(node, "不支持的 Subscript 类型注解(仅支持 t.CArray / t.Callable)") @@ -1817,7 +1825,8 @@ class TypeGenResolve(TypeGenBase.TypeGenBase): elem_ty_single: llvmlite.LLVMType | t.CPtr = self.resolve_annotation_type( pool, sub.slice, imported_modules, from_imports, trans, depth + 1) if elem_ty_single is None: - self.Gen.TypeGenErr.fatal_type_error(sub.slice, "t.CArray[?] 元素类型解析失败") + # 元素类型依赖未就绪(同 L1807 注释):返回 None 交多遍收敛 + return None return llvmlite.Ptr(pool, elem_ty_single) # 双参数形式: t.CArray[elem_ty, count] → [count x elem_ty] tup: ast.Tuple | t.CPtr = (ast.Tuple | t.CPtr)(sub.slice) @@ -1835,7 +1844,15 @@ class TypeGenResolve(TypeGenBase.TypeGenBase): elem_ty: llvmlite.LLVMType | t.CPtr = self.resolve_annotation_type( pool, elem_node, imported_modules, from_imports, trans, depth + 1) if elem_ty is None: - self.Gen.TypeGenErr.fatal_type_error(elem_node, "t.CArray 元素类型解析失败") + # 元素类型依赖未就绪(如 t.CArray[类, N] 中类尚未注册):返回 None + # 交上层多遍收敛,不在此 fatal 中断 Phase 1a 预注册。 + # 根因:阶段2 删 map_t_type stdint 硬编码后,UINT 等只经 CTypedef + # 动态表解析;Phase 1a(declare_only=1)无 vpi 注入 → 依赖 typedef + # 的类(zhuff_code)被跳过 → t.CArray[zhuff_code, N] 元素解析失败 + # 被误 fatal(zhuff.vp L19 根因)。与裸名 CArray 路径(L1760)及 + # ClassGenDef 字段 pending 机制保持一致;真实类型错误由 Phase A + # 收敛检查暴露("Phase A 无法完成翻译")。 + return None # 解析 count(支持整数常量、None、CDefine 常量名、常量表达式如 2*MAX) # t.CArray[elem_ty, None] 等价于单参数形式 → Ptr(elem_ty) # t.CArray[elem_ty, NAME] 其中 NAME: t.CDefine = value → [value x elem_ty]