From 1b8028363462a56effec0dd49cfd97c5806d2aed Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 13 Aug 2026 02:32:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(type):=20=E8=81=94=E5=90=88=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=89=8D=E5=90=91=E8=87=AA=E6=88=91=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E8=AF=AF=E6=9D=80=E6=81=A2=E5=A4=8D=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit json 等类的字段 'JsonValue | t.CPtr' 引用自身类,类体处理中尚未注册(前向自我引用)是合法场景,由 Phase A-pre 多遍注册 + AnnotClassName 恢复处理。恢复类名未注册时回退 Ptr(i8),禁止 fail-fast 误杀。 --- App/lib/core/Gen/TypeGenMixin.vp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/App/lib/core/Gen/TypeGenMixin.vp b/App/lib/core/Gen/TypeGenMixin.vp index da82236..734aeae 100644 --- a/App/lib/core/Gen/TypeGenMixin.vp +++ b/App/lib/core/Gen/TypeGenMixin.vp @@ -1910,12 +1910,12 @@ class TypeGenMixin: other_cls_ty: llvmlite.LLVMType | t.CPtr = HandlesStruct.get_struct_type(other_cls_nm) if other_cls_ty is not None: return llvmlite.Ptr(pool, other_cls_ty) - # fail-fast:CPtr 标记下 other 侧类型完全无法解析, - # 不再静默退化为 i8*,暴露上游类型错误根因。 - # (t.CVoid | t.CPtr → i8* 的合法语义分支在 other_is_cvoid 处已提前返回) - HandlesType.fatal_error( - node, f"联合类型 '{HandlesType.annotation_to_str(node)}' 中类型无法解析", "NameError") - return llvmlite.Ptr(pool, llvmlite.Int8(pool)) # 不可达(fatal_error 已退出) + # 类名未注册:可能是前向自我引用(如 json 的 + # 'JsonValue' | t.CPtr 字段引用自身类,类体处理中 + # 尚未注册)或 Phase A-pre 依赖类延迟到下一遍注册。 + # 回退 Ptr(i8) 由 AnnotClassName 恢复 + 多遍注册收敛 + # 处理,禁止 fail-fast(误杀合法前向引用)。 + return llvmlite.Ptr(pool, llvmlite.Int8(pool)) return llvmlite.Ptr(pool, other_ty) # 无 CPtr 标记:返回第一个非 None(装饰器标记如 CExport/CExtern 被忽略)