{"record":{"id":"7f2bdafc2d1ddc56","repo":"go-delve/delve","slug":"wrong-number-of-arguments-for-s-s","errorCode":null,"errorMessage":"wrong number of arguments for %s.%s","messagePattern":"wrong number of arguments for (.+?)\\.(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":303,"sourceCode":"\t}\n\n\tif depth[len(ctx.ops)] != endDepth {\n\t\treturn 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))\n\t}\n\treturn nil\n}\n\nfunc (ctx *compileCtx) compileAST(t ast.Expr, toplevel bool) error {\n\tswitch node := t.(type) {\n\tcase *ast.CallExpr:\n\t\tif f, ok := node.Fun.(*ast.SelectorExpr); ok && ctx.flags&BreakpointCondition != 0 {\n\t\t\tconst catch = \"catch\"\n\t\t\tif ident, ok := f.X.(*ast.Ident); ok && ident.Name == DelvePackage && f.Sel.Name == catch {\n\t\t\t\tif !toplevel {\n\t\t\t\t\treturn fmt.Errorf(\"%s.%s can only be used at toplevel\", DelvePackage, catch)\n\t\t\t\t}\n\t\t\t\tif len(node.Args) != 1 {\n\t\t\t\t\treturn fmt.Errorf(\"wrong number of arguments for %s.%s\", DelvePackage, catch)\n\t\t\t\t}\n\t\t\t\tctx.pushOp(&DisableErrors{})\n\t\t\t\treturn ctx.compileAST(node.Args[0], false)\n\t\t\t}\n\t\t}\n\t\treturn ctx.compileTypeCastOrFuncCall(node, toplevel)\n\n\tcase *ast.Ident:\n\t\treturn ctx.compileIdent(node)\n\n\tcase *ast.ParenExpr:\n\t\t// otherwise just eval recursively\n\t\treturn ctx.compileAST(node.X, false)\n\n\tcase *ast.SelectorExpr: // <expression>.<identifier>\n\t\tswitch x := node.X.(type) {\n\t\tcase *ast.Ident:\n\t\t\tswitch {","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L285-L321","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncondition 1 delve.catch(f, arg)\n// after\ncondition 1 delve.catch(f(arg))","handlingStrategy":"validation","validationCode":"func validateCatchArgs(cond string) error {\n    expr, err := parser.ParseExpr(cond)\n    if err != nil { return err }\n    if call, ok := expr.(*ast.CallExpr); ok {\n        if len(call.Args) != 1 {\n            return fmt.Errorf(\"delve.catch takes exactly 1 argument, got %d\", len(call.Args))\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"wrong number of arguments for delve.catch\") {\n    // fix arity: pass a single combined expression\n    return setCondition(bp, \"delve.catch(a && f(b))\")\n}","preventionTips":["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"],"tags":["debugger","eval","delve-catch","argument-count"],"backgroundTag":"wrong-argument-count","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}