From 3c6041c97c670f86e68f604f461994b04f982a8f Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 14 Oct 2026 17:13:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(viperc/diag):=20=E6=8A=8A=E2=80=9C=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=AE=9E=E5=8F=82=E4=BD=8D=E7=BD=AE=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=82=B9=E4=B8=8B=E6=B2=89=E5=88=B0=20transl?= =?UTF-8?q?ate=5Fcall=5Farg=EF=BC=88=E8=A6=86=E7=9B=96=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E8=B7=AF=E5=BE=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TEMP-DIAG 实测:node=0 curarg=0 trace=1 top=11 —— 节点是合成的(无行号),但“当前实参 位置”压根没被记录,说明该构造器调用没走 CallGenLib 的参数循环,兜底只能退回栈帧(函数定义行)。 改为在**所有调用实参的公共入口** CallGenBase.translate_call_arg 顶部记录(它持有 arg_node), 并移除 CallGenLib 里的重复挂点。这样任何调用路径(含构造器)都能把报错定位到具体实参表达式。 --- App/lib/core/Gen/Call/CallGenBase.vp | 4 ++++ App/lib/core/Gen/Call/CallGenLib.vp | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/App/lib/core/Gen/Call/CallGenBase.vp b/App/lib/core/Gen/Call/CallGenBase.vp index 9756557..05bbbb4 100644 --- a/App/lib/core/Gen/Call/CallGenBase.vp +++ b/App/lib/core/Gen/Call/CallGenBase.vp @@ -146,6 +146,10 @@ novirtual class CallGenBase: trans: HT.Translator*, callee_name: str, arg_idx: int, arg_node: ast.AST*, fpty: mlirlite.LLVMType*, use_ctx: str = "param") -> mlirlite.Value*: """Translate a call argument; value-reference params take the address (ref) or a temp copy (temp).""" + # 记录“当前实参位置”:被调者内部若因**合成节点**(lineno==0,如构造器内联出的参数赋值) + # 报错,可据此把报错精确定位到这个实参表达式(如 `&_on_submit`),而不是退回函数定义行。 + if arg_node is not None: + self.Gen.TypeGenBase.set_cur_arg(self.Gen.TypeGenResolve.get_current_file(), arg_node.lineno, arg_node.col_offset + 1) mode: int = self._auto_addr_mode(callee_name, arg_idx) if mode == 0: return self.Gen.ExprGen.translate_value(builder, pool, mod, arg_node, None, 0, trans, fpty, use_ctx) diff --git a/App/lib/core/Gen/Call/CallGenLib.vp b/App/lib/core/Gen/Call/CallGenLib.vp index 4a32cd0..449824e 100644 --- a/App/lib/core/Gen/Call/CallGenLib.vp +++ b/App/lib/core/Gen/Call/CallGenLib.vp @@ -221,9 +221,6 @@ novirtual class CallGenLib(CallGenBase.CallGenBase): if self.Gen.ExprGenBase._str_rejects_ptr_kind(cur) != 0: if VpiReader._vpi_param_annot_seg_is(sha1_buf, cls_nm, meth_nm, idx, "str") != 0 or VpiReader._vpi_param_annot_seg_is(sha1_buf, cls_nm, meth_nm, idx, "bytes") != 0: self.Gen.ExprGenBase.fail_if_str_annot_agg_ptr(cur, 1, arg_node) - # 记录当前实参位置:被调者内部报错若是合成节点(无行号),可据此定位到这个实参表达式 - if arg_node is not None: - self.Gen.TypeGenBase.set_cur_arg(self.Gen.TypeGenResolve.get_current_file(), arg_node.lineno, arg_node.col_offset + 1) node_v = self._coerce_arg_value_to_ty(pool, builder, node_v, tgt_ty, arg_node, trans, tpl_src) if new_head is None: new_head = node_v else: new_tail.Next = node_v