{"record":{"id":"448f4098ea6f59bd","repo":"go-delve/delve","slug":"expression-q-is-not-a-function","errorCode":null,"errorMessage":"expression %q is not a function","messagePattern":"expression %q is not a function","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/fncall.go","lineNumber":512,"sourceCode":"\tcase \"arm64\", \"ppc64le\", \"loong64\":\n\t\tif err := setLR(thread, regs.PC()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn setPC(thread, callAddr)\n\n\tdefault:\n\t\tpanic(\"not implemented\")\n\t}\n}\n\n// funcCallEvalFuncExpr evaluates expr.Fun and returns the function that we're trying to call.\n// If allowCalls is false function calls will be disabled even if scope.callCtx != nil\nfunc funcCallEvalFuncExpr(scope *EvalScope, stack *evalStack, fncall *functionCallState) error {\n\tbi := scope.BinInfo\n\n\tfnvar := stack.peek()\n\tif fnvar.Kind != reflect.Func {\n\t\treturn fmt.Errorf(\"expression %q is not a function\", astutil.ExprToString(fncall.expr.Fun))\n\t}\n\tfnvar.loadValue(LoadConfig{false, 0, 0, 0, 0, 0})\n\tif fnvar.Unreadable != nil {\n\t\treturn fnvar.Unreadable\n\t}\n\tif fnvar.Base == 0 {\n\t\treturn errors.New(\"nil pointer dereference\")\n\t}\n\tfncall.fn = bi.PCToFunc(fnvar.Base)\n\tif fncall.fn == nil {\n\t\treturn fmt.Errorf(\"could not find DIE for function %q\", astutil.ExprToString(fncall.expr.Fun))\n\t}\n\tif !fncall.fn.cu.isgo {\n\t\treturn errNotAGoFunction\n\t}\n\tfncall.closureAddr = fnvar.closureAddr\n\n\tvar err error","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L494-L530","documentation":"funcCallEvalFuncExpr evaluates the function expression of a call injection and expects the resulting variable to have Kind == reflect.Func. If the expression evaluates to anything else (int, struct, pointer, etc.) Delve cannot inject a call and returns this error naming the original expression text.","triggerScenarios":"Using 'call <expr>' in the terminal or CallFunction API where the expression's evaluated value is not of function kind, e.g. calling a variable holding an int or a non-function field.","commonSituations":"Typo in function name that resolves to a variable of another type; calling a func-typed field after an incorrect type assumption; calling through an expression that evaluated to nil interface.","solutions":["Check the expression's type with 'print <expr>' before calling","Fix the expression so it names or produces a function value","If the value comes from an unreadable/optimized variable, disable optimizations or rebuild"],"exampleFix":"// before\ndlv> call myCounter\n// error: expression \"myCounter\" is not a function\n// after\ndlv> call myCounter.Inc()","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isFuncVar(v *proc.Variable) bool { return v != nil && v.Kind == reflect.Func }","tryCatchPattern":"if err := dbg.CallFunction(goid, expr, nil); err != nil {\n    if strings.Contains(err.Error(), \"is not a function\") {\n        // surface a clearer message: evaluate expr type first\n    }\n}","preventionTips":["Run 'print <expr>' to confirm the value is a function before 'call'","Check the type of struct fields you intend to call"],"tags":["go","debugger","call-injection","type-mismatch"],"backgroundTag":"expression-not-a-function","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}