{"record":{"id":"eb6393c32ee0fb51","repo":"go-delve/delve","slug":"wrong-number-of-arguments-to-cap-d","errorCode":null,"errorMessage":"wrong number of arguments to cap: %d","messagePattern":"wrong number of arguments to cap: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":1894,"sourceCode":"\t\t// sign extension\n\t\tr |= ^uint64(0) &^ mask\n\t}\n\treturn r\n}\n\nvar supportedBuiltins = map[string]func([]*Variable, []ast.Expr) (*Variable, error){\n\t\"cap\":     capBuiltin,\n\t\"len\":     lenBuiltin,\n\t\"complex\": complexBuiltin,\n\t\"imag\":    imagBuiltin,\n\t\"real\":    realBuiltin,\n\t\"min\":     minBuiltin,\n\t\"max\":     maxBuiltin,\n}\n\nfunc capBuiltin(args []*Variable, nodeargs []ast.Expr) (*Variable, error) {\n\tif len(args) != 1 {\n\t\treturn nil, fmt.Errorf(\"wrong number of arguments to cap: %d\", len(args))\n\t}\n\n\targ := args[0]\n\tinvalidArgErr := fmt.Errorf(\"invalid argument %s (type %s) for cap\", astutil.ExprToString(nodeargs[0]), arg.TypeString())\n\n\tswitch arg.Kind {\n\tcase reflect.Ptr:\n\t\targ = arg.maybeDereference()\n\t\tif arg.Kind != reflect.Array {\n\t\t\treturn nil, invalidArgErr\n\t\t}\n\t\tfallthrough\n\tcase reflect.Array:\n\t\treturn newConstant(constant.MakeInt64(arg.Len), arg.bi, arg.mem), nil\n\tcase reflect.Slice:\n\t\treturn newConstant(constant.MakeInt64(arg.Cap), arg.bi, arg.mem), nil\n\tcase reflect.Chan:\n\t\targ.loadValue(LoadFullValue())","sourceCodeStart":1876,"sourceCodeEnd":1912,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L1876-L1912","documentation":"Error \"wrong number of arguments to cap: %d\" thrown in go-delve/delve.","triggerScenarios":"Thrown at pkg/proc/eval.go:1894 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}