From 19feb40e8ca525206c29eccc22aba054d8270a87 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Fri, 16 Oct 2026 19:26:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(call):=20=E5=AE=9E=E5=8F=82=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=E4=B8=8E=E8=A2=AB=E8=B0=83=E6=96=B9=E4=B8=8D=E7=AC=A6?= =?UTF-8?q?=E6=97=B6=E5=89=8D=E7=AB=AF=20fail-fast=20-=20=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=BC=8F=E5=88=B0=20LLVM=20verifier(=E5=90=AB=20EH=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=89=A3=E9=99=A4=E4=B8=8E=E5=8F=AF=E5=8F=98?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=94=BE=E8=A1=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Gen/Call/CallGenLeafKit.vp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/App/lib/core/Gen/Call/CallGenLeafKit.vp b/App/lib/core/Gen/Call/CallGenLeafKit.vp index a005a9f..a009942 100644 --- a/App/lib/core/Gen/Call/CallGenLeafKit.vp +++ b/App/lib/core/Gen/Call/CallGenLeafKit.vp @@ -117,6 +117,23 @@ novirtual class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): # ============================================================ def _emit_eh_guarded_call(self, builder: mlirlite.IRBuilder*, pool: memhub.MemBuddy*, mod: mlirlite.LLVMModule*, trans: HT.Translator*, func: mlirlite.Function*, call_name: str, head: mlirlite.Value*, count: int, ret_ty: mlirlite.LLVMType*, is_variadic: int) -> mlirlite.Value*: """Call a function with try-except EH detection; returns the call result (positioned at ok block)""" + # Argument-count check (fail-fast at the front end instead of leaking to the LLVM verifier). + # Callee params include the injected EH out-params (%__eh_msg_out__/__eh_code_out__), which the + # caller does not pass explicitly (they are appended later in this function), so subtract them. + if func is not None and is_variadic == 0: + n_declared: int = 0 + p_chk: mlirlite.Param* = mlirlite.function_get_param_head(func) + while p_chk is not None: + n_declared += 1 + p_chk = mlirlite.param_get_next(p_chk) + if self._func_has_eh_params(func) == 1: n_declared = n_declared - 2 + if n_declared >= 0 and count != n_declared: + fname_chk: str = mlirlite.function_get_name(func) + if fname_chk is None: fname_chk = call_name + self.Gen.TypeGenErr.fatal_error( + None, + f"Argument count mismatch calling '{fname_chk}': the callee declares {n_declared} parameter(s) but the call passes {count} argument(s)", + "TypeError") if trans is None or self._func_has_eh_params(func) == 0: return mlirlite.build_call(builder, call_name, head, count, ret_ty, is_variadic) # ---- 1. determine output pointers ---- i8_ty_g: mlirlite.LLVMType* = mlirlite.Int8(pool)