go-delve/delve · error
wrong number of arguments for %s.%s
Error message
wrong number of arguments for %s.%s
What it means
The `delve.catch(...)` builtin in breakpoint conditions takes exactly one argument (the expression whose errors should be suppressed). The compiler raises this error at compile time when the call has any other number of arguments.
Source
Thrown at pkg/proc/evalop/evalcompile.go:303
}
if depth[len(ctx.ops)] != endDepth {
return fmt.Errorf("internal debugger error: depth check failed: depth at the end is not %d (got %d)\n%s", depth[len(ctx.ops)], endDepth, Listing(depth, ctx.ops))
}
return nil
}
func (ctx *compileCtx) compileAST(t ast.Expr, toplevel bool) error {
switch node := t.(type) {
case *ast.CallExpr:
if f, ok := node.Fun.(*ast.SelectorExpr); ok && ctx.flags&BreakpointCondition != 0 {
const catch = "catch"
if ident, ok := f.X.(*ast.Ident); ok && ident.Name == DelvePackage && f.Sel.Name == catch {
if !toplevel {
return fmt.Errorf("%s.%s can only be used at toplevel", DelvePackage, catch)
}
if len(node.Args) != 1 {
return fmt.Errorf("wrong number of arguments for %s.%s", DelvePackage, catch)
}
ctx.pushOp(&DisableErrors{})
return ctx.compileAST(node.Args[0], false)
}
}
return ctx.compileTypeCastOrFuncCall(node, toplevel)
case *ast.Ident:
return ctx.compileIdent(node)
case *ast.ParenExpr:
// otherwise just eval recursively
return ctx.compileAST(node.X, false)
case *ast.SelectorExpr: // <expression>.<identifier>
switch x := node.X.(type) {
case *ast.Ident:
switch {View on GitHub (pinned to a23773e6c3)
Solutions
- Pass exactly one argument: the whole expression to evaluate, e.g. `delve.catch(f(x) > 3)`
- If you need multiple calls, combine them into one expression with &&/||, or wrap in a helper function and call it once
- Remove any extra arguments and move them inside the single expression
Example fix
// before condition 1 delve.catch(f, arg) // after condition 1 delve.catch(f(arg))
Defensive patterns
Strategy: validation
Validate before calling
func validateCatchArgs(cond string) error {
expr, err := parser.ParseExpr(cond)
if err != nil { return err }
if call, ok := expr.(*ast.CallExpr); ok {
if len(call.Args) != 1 {
return fmt.Errorf("delve.catch takes exactly 1 argument, got %d", len(call.Args))
}
}
return nil
} Try / catch
if err != nil && strings.Contains(err.Error(), "wrong number of arguments for delve.catch") {
// fix arity: pass a single combined expression
return setCondition(bp, "delve.catch(a && f(b))")
} Prevention
- Always pass one expression; combine multiple checks with && / ||
- Do not pass function-plus-arguments separately — call the function inside the expression
- Test the condition with `print delve.catch(...)` before installing it
When it happens
Trigger: Evaluating or compiling `delve.catch()` with no arguments, `delve.catch(a, b)` with multiple arguments, or zero-argument typos like `delve.catch()` copied from documentation placeholders.
Common situations: Misreading of the API where users think catch takes a function plus extra args (`delve.catch(f, arg)`); refactoring left an empty catch; forgetting to pass the condition body.
Related errors
- %s.%s can only be used at toplevel
- wrong number of arguments for runtime.frame
- not enough arguments to %s
- can not convert value of type %s to int
- can not convert value of type %s to uint
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/7f2bdafc2d1ddc56.
Report an issue: GitHub.