go-delve/delve · error
expected integer value for frame, got %v
Error message
expected integer value for frame, got %v
What it means
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.
Source
Thrown at pkg/proc/evalop/evalcompile.go:359
case *ast.CallExpr:
ident, ok := x.Fun.(*ast.SelectorExpr)
if ok {
f, ok := ident.X.(*ast.Ident)
if ok && f.Name == "runtime" && ident.Sel.Name == "frame" {
if len(x.Args) != 1 {
return fmt.Errorf("wrong number of arguments for runtime.frame")
}
switch arg := x.Args[0].(type) {
case *ast.BasicLit:
fr, err := strconv.ParseInt(arg.Value, 10, 8)
if err != nil {
return err
}
// Push local onto the stack to be evaluated in the new frame context.
ctx.pushOp(&PushLocal{Name: node.Sel.Name, Frame: fr})
return nil
default:
return fmt.Errorf("expected integer value for frame, got %v", arg)
}
}
}
return ctx.compileUnary(node.X, &Select{node.Sel.Name})
case *ast.BasicLit: // try to accept "package/path".varname syntax for package variables
s, err := strconv.Unquote(x.Value)
if err != nil {
return err
}
ctx.pushOp(&PushPackageVarOrSelect{Name: s, Sel: node.Sel.Name, NameIsString: true})
default:
return ctx.compileUnary(node.X, &Select{node.Sel.Name})
}
case *ast.TypeAssertExpr: // <expression>.(<type>)
return ctx.compileTypeAssert(node)View on GitHub (pinned to a23773e6c3)
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
Example fix
// before
(dlv) print runtime.frame("-1").x
// error: expected integer value for frame, got "-1"
// after
(dlv) print runtime.frame(-1).x Defensive patterns
Strategy: validation
Validate before calling
func validateFrameArg(cond string) error {
expr, _ := parser.ParseExpr(cond)
var bad error
ast.Inspect(expr, func(n ast.Node) bool {
if call, ok := n.(*ast.CallExpr); ok {
if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
if id, _ := sel.X.(*ast.Ident); id != nil && id.Name == "runtime" && sel.Sel.Name == "frame" {
if len(call.Args) == 1 {
if lit, ok := call.Args[0].(*ast.BasicLit); !ok || lit.Kind != token.INT {
bad = fmt.Errorf("runtime.frame arg must be an integer literal")
}
}
}
}
}
return true
})
return bad
} Type guard
func isIntLit(n ast.Expr) bool {
lit, ok := n.(*ast.BasicLit)
return ok && lit.Kind == token.INT
} Try / catch
if err != nil && strings.Contains(err.Error(), "expected integer value for frame") {
// strip quotes / convert to plain integer literal and retry
return setCondition(bp, "runtime.frame(-1).x")
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- wrong number of arguments for runtime.frame
- can not convert value of type %s to int
- can not convert value of type %s to uint
- %s has no member %s
- %s (type %s) has no member %s
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/3dec65df9e63290b.
Report an issue: GitHub.