go-delve/delve · error
expression %q is not a function
Error message
expression %q is not a function
What it means
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.
Source
Thrown at pkg/proc/fncall.go:512
case "arm64", "ppc64le", "loong64":
if err := setLR(thread, regs.PC()); err != nil {
return err
}
return setPC(thread, callAddr)
default:
panic("not implemented")
}
}
// funcCallEvalFuncExpr evaluates expr.Fun and returns the function that we're trying to call.
// If allowCalls is false function calls will be disabled even if scope.callCtx != nil
func funcCallEvalFuncExpr(scope *EvalScope, stack *evalStack, fncall *functionCallState) error {
bi := scope.BinInfo
fnvar := stack.peek()
if fnvar.Kind != reflect.Func {
return fmt.Errorf("expression %q is not a function", astutil.ExprToString(fncall.expr.Fun))
}
fnvar.loadValue(LoadConfig{false, 0, 0, 0, 0, 0})
if fnvar.Unreadable != nil {
return fnvar.Unreadable
}
if fnvar.Base == 0 {
return errors.New("nil pointer dereference")
}
fncall.fn = bi.PCToFunc(fnvar.Base)
if fncall.fn == nil {
return fmt.Errorf("could not find DIE for function %q", astutil.ExprToString(fncall.expr.Fun))
}
if !fncall.fn.cu.isgo {
return errNotAGoFunction
}
fncall.closureAddr = fnvar.closureAddr
var err errorView on GitHub (pinned to a23773e6c3)
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
Example fix
// before dlv> call myCounter // error: expression "myCounter" is not a function // after dlv> call myCounter.Inc()
Defensive patterns
Strategy: type-guard
Type guard
func isFuncVar(v *proc.Variable) bool { return v != nil && v.Kind == reflect.Func } Try / catch
if err := dbg.CallFunction(goid, expr, nil); err != nil {
if strings.Contains(err.Error(), "is not a function") {
// surface a clearer message: evaluate expr type first
}
} Prevention
- Run 'print <expr>' to confirm the value is a function before 'call'
- Check the type of struct fields you intend to call
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- variable to reslice is not an array, slice, or map
- internal debugger error: eval program finished without error
- internal debugger error: could not undo injected call during
- invalid argument 1 %s (type %s) to complex
- invalid argument 2 %s (type %s) to complex
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/448f4098ea6f59bd.
Report an issue: GitHub.