From 4807012bd8d4d5de2fb606db2c26e305c62858c2 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Mon, 28 Sep 2026 17:02:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(CallGenBase):=20struct=20=E5=AD=97=E9=9D=A2?= =?UTF-8?q?=E9=87=8F=E5=AD=97=E6=AE=B5=E9=93=BE=E8=A1=A8=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=AF=AF=E6=B3=A8=E8=A7=A3=20Function*=20=E2=86=92=20ParamNode?= =?UTF-8?q?*=EF=BC=88Vipeye=20922/927=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 事实:includes/llvmlite/__types.vp 里 new_param_node -> rawptr[ParamNode]、paramnode_set_next(node: rawptr[ParamNode], nxt: rawptr[ParamNode])、Struct(fields: rawptr[ParamNode], ...),而本处 th_st/tt_st/en_st 被注解成 llvmlite.Function*(Function 与 ParamNode 是不相关类)⇒ 严格指针规则下这两处实参传递被判「struct↔struct 隐式转换已禁止」。 修法:把注解改成真实类型 llvmlite.ParamNode*(不需要、也不应该 t.CPtr 强转——变量本来就是 ParamNode,强转只是把类型错误重新掩盖)。 --- App/lib/core/Gen/Call/CallGenBase.vp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/App/lib/core/Gen/Call/CallGenBase.vp b/App/lib/core/Gen/Call/CallGenBase.vp index b682c53..af486f1 100644 --- a/App/lib/core/Gen/Call/CallGenBase.vp +++ b/App/lib/core/Gen/Call/CallGenBase.vp @@ -898,8 +898,12 @@ novirtual class CallGenBase: # struct 字面量 {T1, T2, ...}(tuple 打包返回类型)必须在 * 检查之前,否则内含 * 会被误判为 i8*(破坏 tuple 解包) if s < e and buf[s] == '{': - th_st: llvmlite.Function* = None - tt_st: llvmlite.Function* = None + # 字段链表节点必须是 llvmlite.ParamNode(new_param_node 返回 rawptr[ParamNode], + # paramnode_set_next / Struct 的形参也都是 rawptr[ParamNode])。原先误注解为 + # Function*(与 ParamNode 是不相关类),严格指针规则下这两处的实参传递会被判 + # 「struct↔struct 隐式转换已禁止」;改注解即根治,不需要也不应该加强转。 + th_st: llvmlite.ParamNode* = None + tt_st: llvmlite.ParamNode* = None tc_st: int = 0 ps_st: sizet = s + 1 while ps_st < e and buf[ps_st] != '}': @@ -914,7 +918,7 @@ novirtual class CallGenBase: if ee_st > es_st: et_st: llvmlite.LLVMType* = self._ParseLLVMRetTyStr(pool, buf, es_st, ee_st) if et_st is None: return None - en_st: llvmlite.Function* = llvmlite.new_param_node(pool, et_st) + en_st: llvmlite.ParamNode* = llvmlite.new_param_node(pool, et_st) if en_st is None: return None if th_st is None: th_st = en_st