fix(tpv): 注解 mangled 名算键统一——补回丢失的 from_imports(D25 根因第 1 步)
- 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)
This commit is contained in:
1 parent
967095df5b
commit
ced50bd78b
1 file changed
+10
-1
@@ -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 不可用时,只返回裸类名(向后兼容)
|
||||
|
||||
Reference in new issue
Block a user