From d921dcd9e760d4c1671d43f563fd66ebe5eebc07 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 8 Oct 2026 21:34:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20willFree=20=E5=BD=A2=E5=8F=82?= =?UTF-8?q?=E8=A1=A8=E8=AE=BF=E9=97=AE=E5=85=88=E8=BD=AC=20Arguments*?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=20TPC=20=E4=BE=A7=20MemberLookupFai?= =?UTF-8?q?lFast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FunctionDef.args 的字段静态类型是 AST*,直接写 fn.args.args 会在 AST 类上查 args(class_members=7 不含 args)。改为先 ast.Arguments*(fn.args) 再取 .args 列表,与 VpiReader / FuncGenMixin / ClassGenVTable 等既有写法一致。 --- App/lib/core/Gen/GenApi.vp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/App/lib/core/Gen/GenApi.vp b/App/lib/core/Gen/GenApi.vp index b645464..2f124ba 100644 --- a/App/lib/core/Gen/GenApi.vp +++ b/App/lib/core/Gen/GenApi.vp @@ -377,10 +377,16 @@ def _WillFreeArgIndex(fn: ast.FunctionDef*, arg: ast.AST*) -> int: if arg is None: fatal_error(arg, "@willFree(...) requires a parameter name or its 0-based position", "LifetimeError") return -1 - if fn.args is None or fn.args.args is None: + # FunctionDef.args 的字段静态类型是 AST*(见 includes/ast/stmts.vp),必须先转成 Arguments* + # 才能再取 .args 列表;直接写 fn.args.args 会去 AST 类查 'args' 触发 MemberLookupFailFast。 + if fn.args is None: fatal_error(arg, "@willFree(...) cannot be used here: the definition has no parameter list", "LifetimeError") return -1 - pl: list[ast.AST*]* = fn.args.args + fargs: ast.Arguments* = ast.Arguments*(fn.args) + if fargs is None or fargs.args is None: + fatal_error(arg, "@willFree(...) cannot be used here: the definition has no parameter list", "LifetimeError") + return -1 + pl: list[ast.AST*]* = fargs.args pn: sizet = len(pl) if arg.kind() == ast.ASTKind.Name: nma: ast.Name* = ast.Name*(arg)