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)