{"record":{"id":"0703a751dfed9ea2","repo":"go-delve/delve","slug":"could-not-evaluate-function-or-type-s-v","errorCode":null,"errorMessage":"could not evaluate function or type %s: %v","messagePattern":"could not evaluate function or type (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":584,"sourceCode":"\t\treturn err\n\t}\n\n\tfnnode := node.Fun\n\n\t// remove all enclosing parenthesis from the type name\n\tfnnode = removeParen(fnnode)\n\n\ttargetTypeStr := astutil.ExprToString(removeParen(node.Fun))\n\tstyp, err := ctx.FindTypeExpr(fnnode)\n\tif err != nil {\n\t\tswitch targetTypeStr {\n\t\tcase \"[]byte\", \"[]uint8\":\n\t\t\tstyp = godwarf.FakeSliceType(godwarf.FakeBasicType(\"uint\", 8))\n\t\tcase \"[]int32\", \"[]rune\":\n\t\t\tstyp = godwarf.FakeSliceType(godwarf.FakeBasicType(\"int\", 32))\n\t\tdefault:\n\t\t\tif ambiguousErr != nil && err == reader.ErrTypeNotFound {\n\t\t\t\treturn fmt.Errorf(\"could not evaluate function or type %s: %v\", astutil.ExprToString(node.Fun), ambiguousErr)\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\n\tctx.pushOp(&TypeCast{DwarfType: styp, Node: node})\n\treturn nil\n}\n\nfunc (ctx *compileCtx) compileBuiltinCall(builtin string, args []ast.Expr) error {\n\tfor _, arg := range args {\n\t\terr := ctx.compileAST(arg, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tctx.pushOp(&BuiltinCall{builtin, args})\n\treturn nil","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L566-L602","documentation":"When compiling a type cast or function call, Delve attempts to resolve node.Fun as a type; if the type lookup fails with reader.ErrTypeNotFound and there was an earlier ambiguity (ambiguousErr), it reports 'could not evaluate function or type <expr>: <ambiguous error>'. This surfaces when the name is ambiguous between a function and a type, or the DWARF type reader cannot uniquely resolve the referenced type.","triggerScenarios":"A cast expression like 'mypkg.T(x)' where T's DWARF type cannot be found (ErrTypeNotFound) while a prior lookup attempt recorded an ambiguity; calling a name that could be either a function or a parametric/generic type; types from Cgo or incomplete DWARF.","commonSituations":"Debugging generics-heavy code where instantiated type names are hard to resolve; stripped or partial DWARF (e.g. from cgo or external linkers); name collisions between a function and a type in different packages.","solutions":["Fully qualify the type/function with its package path in the expression","Rebuild the binary with complete DWARF (avoid -w/-s, avoid stripping); for cgo ensure debug info is generated","If a name is ambiguous, rename the cast target or disambiguate with a temporary variable of the desired type","Upgrade delve — generic/parametric type resolution improves across versions"],"exampleFix":"// before\n(dlv) print T(v)\n// after\n(dlv) print (*main.T)(v) // or fully qualified: mypkg.T(v)","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"_, err := eval(\"mypkg.T(x)\")\nif err != nil && strings.Contains(err.Error(), \"could not evaluate function or type\") {\n\t// retry with fully-qualified type name or check binary DWARF completeness\n}","preventionTips":["Fully qualify types in casts","Do not strip binaries (-w/-s off)","Keep delve updated for better generics support"],"tags":["debugger","dwarf","type-resolution"],"backgroundTag":"symbol-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}