From 58d61badcbea957978c3298f2c42615230b8b313 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 29 Aug 2026 10:14:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(tpv):=20=E8=B7=A8=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=94=AF=E6=8C=81=20import=20=E5=88=AB=E5=90=8D?= =?UTF-8?q?=EF=BC=88GenApi.translate=5Fprintf=5Fcall=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 模块限定调用 GenApi.translate_printf_call 的 mod_ret_sha1 用 LookupSha1ByModName(别名) 查不到 → None → 误走裸名外部函数路径 fatal_if_unknown=1 fail-fast 误杀。改经 _resolve_module_sha1(LookupModNameByAlias 别名还原 → 精确/后缀)解析,与 L620-629 模块归属校验的既有模式一致。 --- App/lib/core/Gen/Call/CallGenMixin.vp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/App/lib/core/Gen/Call/CallGenMixin.vp b/App/lib/core/Gen/Call/CallGenMixin.vp index 8c8e4d7..4cc3090 100644 --- a/App/lib/core/Gen/Call/CallGenMixin.vp +++ b/App/lib/core/Gen/Call/CallGenMixin.vp @@ -740,7 +740,17 @@ class CallGenMixin(CallGenBase.CallGenBase): elif at_ret.value is not None and at_ret.value.kind() == ast.ASTKind.Attribute: mod_path_ret = self.Gen.ExprGenAttr._attr_module_path_str(pool, at_ret.value) if mod_path_ret is not None: - mod_ret_sha1 = self._lookup_module_sha1(mod_path_ret) + # import X as Y 别名(如 import lib.core.Gen.GenApi as GenApi): + # 精确模块名查找(LookupSha1ByModName)查不到别名 → None → 误走 + # 裸名外部函数路径 fail-fast 误杀可收敛的模块限定调用 + # (CallGenLeafKit L1327 GenApi.translate_printf_call 根因, + # 同 CreatePipe 模式)。改经 _resolve_module_sha1(别名还原 + # LookupModNameByAlias → 精确/后缀)解析。 + fi_from_rt: str = None + if trans is not None: + fi_from_rt = trans._from_imports + mod_ret_sha1 = self.Gen.StructGen._resolve_module_sha1( + mod_path_ret, fi_from_rt) if mod_ret_sha1 is not None: # 函数内懒 import:VpiReader imports HandlesExprCall, # 顶层 import 会成环(与 _lookup_method_ret_ty_via_vpi 一致)