fix(tpv): 跨模块调用返回类型解析支持 import 别名(GenApi.translate_printf_call)
模块限定调用 GenApi.translate_printf_call 的 mod_ret_sha1 用 LookupSha1ByModName(别名) 查不到 → None → 误走裸名外部函数路径 fatal_if_unknown=1 fail-fast 误杀。改经 _resolve_module_sha1(LookupModNameByAlias 别名还原 → 精确/后缀)解析,与 L620-629 模块归属校验的既有模式一致。
This commit is contained in:
1 parent
8d0241e0c3
commit
58d61badcb
1 file changed
+11
-1
@@ -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 一致)
|
||||
|
||||
Reference in new issue
Block a user