{"record":{"id":"9a973450a61b6faf","repo":"go-delve/delve","slug":"wrong-number-of-arguments-for-runtime-frame","errorCode":null,"errorMessage":"wrong number of arguments for runtime.frame","messagePattern":"wrong number of arguments for runtime\\.frame","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":347,"sourceCode":"\t\t\t\tctx.pushOp(&PushThreadID{})\n\n\t\t\tcase x.Name == \"runtime\" && node.Sel.Name == \"rangeParentOffset\":\n\t\t\t\tctx.pushOp(&PushRangeParentOffset{})\n\n\t\t\tcase x.Name == DelvePackage && node.Sel.Name == BreakpointHitCountVarName:\n\t\t\t\tctx.pushOp(&PushBreakpointHitCount{})\n\n\t\t\tdefault:\n\t\t\t\tctx.pushOp(&PushPackageVarOrSelect{Name: x.Name, Sel: node.Sel.Name})\n\t\t\t}\n\n\t\tcase *ast.CallExpr:\n\t\t\tident, ok := x.Fun.(*ast.SelectorExpr)\n\t\t\tif ok {\n\t\t\t\tf, ok := ident.X.(*ast.Ident)\n\t\t\t\tif ok && f.Name == \"runtime\" && ident.Sel.Name == \"frame\" {\n\t\t\t\t\tif len(x.Args) != 1 {\n\t\t\t\t\t\treturn fmt.Errorf(\"wrong number of arguments for runtime.frame\")\n\t\t\t\t\t}\n\t\t\t\t\tswitch arg := x.Args[0].(type) {\n\t\t\t\t\tcase *ast.BasicLit:\n\t\t\t\t\t\tfr, err := strconv.ParseInt(arg.Value, 10, 8)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Push local onto the stack to be evaluated in the new frame context.\n\t\t\t\t\t\tctx.pushOp(&PushLocal{Name: node.Sel.Name, Frame: fr})\n\t\t\t\t\t\treturn nil\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn fmt.Errorf(\"expected integer value for frame, got %v\", arg)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ctx.compileUnary(node.X, &Select{node.Sel.Name})\n\n\t\tcase *ast.BasicLit: // try to accept \"package/path\".varname syntax for package variables","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L329-L365","documentation":"`runtime.frame(N)` is a Delve expression construct (not a real Go function) that selects a stack frame for subsequent member lookups in an eval expression, e.g. `runtime.frame(-1).x`. It requires exactly one argument; the compiler rejects any other arity at compile time.","triggerScenarios":"Compiling an expression containing `runtime.frame` with zero or more than one argument, e.g. `runtime.frame().x`, `runtime.frame(1, 2).x`, or a leftover empty call after editing.","commonSituations":"Users pattern-match ordinary Go function-call syntax and omit or add arguments; templates with placeholders left unedited in breakpoint conditions.","solutions":["Supply exactly one integer frame argument: `runtime.frame(-2).varname` (0 = current frame, negative = callers)","Split multi-frame access into separate evaluations, one per frame","Correct the expression in the breakpoint condition or watch entry"],"exampleFix":"// before\n(dlv) print runtime.frame().x\n// error: wrong number of arguments for runtime.frame\n// after\n(dlv) print runtime.frame(-1).x","handlingStrategy":"validation","validationCode":"func validateFrameCall(cond string) error {\n    expr, err := parser.ParseExpr(cond)\n    if err != nil { return err }\n    ast.Inspect(expr, func(n ast.Node) bool {\n        if call, ok := n.(*ast.CallExpr); ok {\n            if sel, ok := call.Fun.(*ast.SelectorExpr); ok {\n                if id, ok := sel.X.(*ast.Ident); ok && id.Name == \"runtime\" && sel.Sel.Name == \"frame\" && len(call.Args) != 1 {\n                    err = fmt.Errorf(\"runtime.frame needs exactly 1 arg\")\n                }\n            }\n        }\n        return true\n    })\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"wrong number of arguments for runtime.frame\") {\n    return setCondition(bp, \"runtime.frame(-1).x\") // fix arity\n}","preventionTips":["Always call runtime.frame with exactly one integer literal","Remember it is a delve pseudo-function, not Go's runtime.frame","Use separate expressions for different frames rather than chaining calls"],"tags":["debugger","eval","runtime-frame","argument-count"],"backgroundTag":"wrong-argument-count","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}