fix(gen): 函数指针变量别名(f2: rawptr = f)继承已注册的返回类型签名,修 rawptr 间接调用的签名缺失 fail-fast

This commit is contained in:
TermiNexus committed 2026-10-13 13:26:11 +08:00
1 parent 32599a08c1
commit d3997e0746
1 file changed
+10
+10
View File
@@ -2129,6 +2129,16 @@ novirtual class AssignGenMixin:
if callable_ret is not None:
# Nonzero return already reported inside register_func_ptr_sig; this branch is defensive
if self.Gen.CallGenLeafKit.register_func_ptr_sig(pool, nm.id, callable_ret, aa) != 0: return 0
elif aa.value is not None and aa.value.kind() == ast.ASTKind.Name:
# Function-pointer alias: `f2: rawptr = f` inherits f's already-registered return
# type, so a later indirect call `f2()` can rebuild the callee type. The `rawptr`
# annotation carries no callable information of its own, and without this the indirect
# call would fail fast (see _translate_func_ptr_call's "not registered" error).
src_nm: ast.Name* = ast.Name*(aa.value)
if src_nm.id is not None:
src_ret: mlirlite.LLVMType* = self.Gen.CallGenLeafKit.lookup_func_ptr_ret(src_nm.id)
if src_ret is not None:
if self.Gen.CallGenLeafKit.register_func_ptr_sig(pool, nm.id, src_ret, aa) != 0: return 0
# Value-position volatile call prefix: mark the result slot volatile
if aa.value is not None and aa.value.kind() == ast.ASTKind.Call and (ast.Call*(aa.value)).IsVolatile != 0 and nm.id is not None: