go-delve/delve · error

function calls not allowed without using 'call'

Error message

function calls not allowed without using 'call'

What it means

ErrFuncCallNotAllowed is returned when an expression containing a function call is compiled while function-call injection is disabled, i.e. the expression was submitted without opting into 'call' semantics (EvalExpression vs EvalExpressionWithCalls). It is raised by compileFunctionCall, compileFunctionCallNoPinning, and evalCallInjectionStart in pkg/proc/evalop/evalcompile.go.

Source

Thrown at pkg/proc/evalop/evalcompile.go:20

import (
	"errors"
	"fmt"
	"go/ast"
	"go/constant"
	"go/parser"
	"go/scanner"
	"go/token"
	"strconv"
	"strings"

	"github.com/go-delve/delve/pkg/astutil"
	"github.com/go-delve/delve/pkg/dwarf/godwarf"
	"github.com/go-delve/delve/pkg/dwarf/reader"
)

var (
	ErrFuncCallNotAllowed         = errors.New("function calls not allowed without using 'call'")
	errFuncCallNotAllowedLitAlloc = errors.New("literal can not be allocated because function calls are not allowed without using 'call'")
)

const (
	DelvePackage                       = "delve"
	BreakpointHitCountVarName          = "bphitcount"
	BreakpointHitCountVarNameQualified = DelvePackage + "." + BreakpointHitCountVarName
	DebugPinnerFunctionName            = "runtime.debugPinnerV1"
)

type compileCtx struct {
	evalLookup
	ops        []Op
	allowCalls bool
	curCall    int
	flags      Flags
	pinnerUsed bool
	hasCalls   bool

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Use the 'call' command instead of 'print' for expressions that call functions: call foo(1)
  2. For RPC/API clients, invoke EvalExpressionWithCalls with the appropriate CallKind instead of EvalExpression
  3. Move the function call out of the expression and inspect its inputs/outputs separately

Example fix

// before
dlv> print strings.ToUpper(s)
// after
dlv> call strings.ToUpper(s)
Defensive patterns

Strategy: validation

Validate before calling

// client-side: only pass call expressions to EvalExpressionWithCalls
import "go/ast"
func containsCall(e ast.Expr) bool {
	found := false
	ast.Inspect(e, func(n ast.Node) bool { if _, ok := n.(*ast.CallExpr); ok { found = true }; return !found })
	return found
}

Try / catch

if errors.Is(err, evalop.ErrFuncCallNotAllowed) {
    // re-issue via EvalExpressionWithCalls or the 'call' command
}

Prevention

When it happens

Trigger: Using the 'print'/'eval' command with an expression containing a call like print foo(1); service-layer EvaluateVariable on an expression with calls; any API path that uses CompileAST with call disallowed but the AST contains *ast.CallExpr.

Common situations: User forgets to prefix with 'call' in the Delve CLI; a watch/conditional-breakpoint expression includes a function call where calls are not permitted; RPC clients calling EvalExpression instead of EvalExpressionWithCalls.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/5958aa8f3a37b115. Report an issue: GitHub.