From ced50bd78bf543b92cb19900628ce0942f1e5697 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 12 Sep 2026 14:32:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(tpv):=20=E6=B3=A8=E8=A7=A3=20mangled=20?= =?UTF-8?q?=E5=90=8D=E7=AE=97=E9=94=AE=E7=BB=9F=E4=B8=80=E2=80=94=E2=80=94?= =?UTF-8?q?=E8=A1=A5=E5=9B=9E=E4=B8=A2=E5=A4=B1=E7=9A=84=20from=5Fimports?= =?UTF-8?q?=EF=BC=88D25=20=E6=A0=B9=E5=9B=A0=E7=AC=AC=201=20=E6=AD=A5?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - extract_class_name_from_annotation 的 Subscript 分支递归取 base 时漏传 from_imports(同函数其余调用点都传了),导致同一注解在「派发名 / 查表键 / 注册键」三处算出不同 mangled 名 - 症状:MatchGenMixin._handle_renum_match 两遍对同一裸 list* alloca 分别按 list[ast.ASTptr] 与 list[ast.ClassDefptr] 解释 → .get 误分派 → 节点指针被截断 → StmtGenMixin._translate_stmt_impl ASan 崩溃(D21 复发,见 Debugger/_Type.md D25) --- App/lib/core/Gen/Type/TypeGenResolve.vp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/App/lib/core/Gen/Type/TypeGenResolve.vp b/App/lib/core/Gen/Type/TypeGenResolve.vp index 33f4d20..a7611dd 100644 --- a/App/lib/core/Gen/Type/TypeGenResolve.vp +++ b/App/lib/core/Gen/Type/TypeGenResolve.vp @@ -1625,7 +1625,16 @@ class TypeGenResolve(TypeGenBase.TypeGenBase): return self.extract_class_name_from_annotation( sub.slice, imported_modules, pool, from_imports) return None - base_name: str = self.extract_class_name_from_annotation(sub.value, imported_modules, pool) + # [D25 根因修复] 递归取 base 时必须把 `from_imports` 一并下传: + # 此前这里丢掉了第 4 个参数,导致同一份注解在「派发名(本函数)/ + # 查表键(_resolve_generic_subscript_ty)/ 注册键(_specialize_generic_class)」 + # 三处算出的 mangled 名可能不同 —— 例如 `list[ast.AST | t.CPtr]` 的 + # 元素段在带/不带 from_imports 时规范化结果不一致,进而出现 + # 「alloca 是裸 list*、pass1 按 list[ast.ASTptr] 解释、pass2 按 + # list[ast.ClassDefptr] 解释」的分裂(MatchGenMixin._handle_renum_match + # 崩溃根因,见 Debugger/_Type.md D25)。其余调用点(1625、1650 等)均已传。 + base_name: str = self.extract_class_name_from_annotation( + sub.value, imported_modules, pool, from_imports) if base_name is None: return None # pool 不可用时,只返回裸类名(向后兼容)