{"record":{"id":"3dec65df9e63290b","repo":"go-delve/delve","slug":"expected-integer-value-for-frame-got-v","errorCode":null,"errorMessage":"expected integer value for frame, got %v","messagePattern":"expected integer value for frame, got (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":359,"sourceCode":"\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\n\t\t\ts, err := strconv.Unquote(x.Value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tctx.pushOp(&PushPackageVarOrSelect{Name: s, Sel: node.Sel.Name, NameIsString: true})\n\n\t\tdefault:\n\t\t\treturn ctx.compileUnary(node.X, &Select{node.Sel.Name})\n\t\t}\n\n\tcase *ast.TypeAssertExpr: // <expression>.(<type>)\n\t\treturn ctx.compileTypeAssert(node)","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L341-L377","documentation":"The argument to the `runtime.frame(N)` expression construct must be an integer literal (it is parsed with strconv.ParseInt at compile time and pushed as a PushLocal/Frame offset). Any other literal kind — string, char, float, etc. — is rejected with this compile-time error naming the offending AST node.","triggerScenarios":"Compiling `runtime.frame(\"1\").x`, `runtime.frame(1.0).x`, or passing a variable/complex expression where a plain integer literal is expected (the switch only accepts *ast.BasicLit parsed as an int8).","commonSituations":"Quoting the frame number out of shell habit (`runtime.frame(\"-1\")`), assuming variables or computed expressions are allowed as the frame argument, or pasting code from other debuggers where frame selectors accept expressions.","solutions":["Use a bare integer literal without quotes: `runtime.frame(-1).x`","Use an integer within int8 range (-128..127); large frame offsets must be narrowed","If you need a dynamic frame, switch frames in the CLI (`frame -1`, `up`/`down`) instead of using the expression form"],"exampleFix":"// before\n(dlv) print runtime.frame(\"-1\").x\n// error: expected integer value for frame, got \"-1\"\n// after\n(dlv) print runtime.frame(-1).x","handlingStrategy":"validation","validationCode":"func validateFrameArg(cond string) error {\n    expr, _ := parser.ParseExpr(cond)\n    var bad error\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, _ := sel.X.(*ast.Ident); id != nil && id.Name == \"runtime\" && sel.Sel.Name == \"frame\" {\n                    if len(call.Args) == 1 {\n                        if lit, ok := call.Args[0].(*ast.BasicLit); !ok || lit.Kind != token.INT {\n                            bad = fmt.Errorf(\"runtime.frame arg must be an integer literal\")\n                        }\n                    }\n                }\n            }\n        }\n        return true\n    })\n    return bad\n}","typeGuard":"func isIntLit(n ast.Expr) bool {\n    lit, ok := n.(*ast.BasicLit)\n    return ok && lit.Kind == token.INT\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"expected integer value for frame\") {\n    // strip quotes / convert to plain integer literal and retry\n    return setCondition(bp, \"runtime.frame(-1).x\")\n}","preventionTips":["Never quote the frame number: use runtime.frame(-1), not runtime.frame(\"-1\")","Keep the value within int8 range (-128..127)","Use CLI frame switching (up/down/frame) for dynamic frame selection"],"tags":["debugger","eval","runtime-frame","argument-type"],"backgroundTag":"invalid-argument-type","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}