go-delve/delve · error

error evaluating %q as argument %d in function %s: %v

Error message

error evaluating %q as argument %d in function %s: %v

What it means

During compile of a function call WITHOUT debug pinning, each argument expression is compiled via compileAST; if any argument fails to compile, the error is wrapped as 'error evaluating "<arg>" as argument N in function <fn>: <cause>'. The wrapper preserves the underlying cause (unsupported syntax, unknown symbol, etc.) and adds which argument of which call failed.

Source

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

	if hasFunc {
		jmpif = &Jump{When: JumpIfFalse, Pop: true}
		ctx.pushOp(jmpif)
	}
	ctx.pushOp(&Pop{})
	err = ctx.compileAST(node.Fun, false)
	if err != nil {
		return err
	}
	if jmpif != nil {
		jmpif.Target = len(ctx.ops)
	}

	ctx.pushOp(&CallInjectionSetTarget{id: id})

	for i, arg := range node.Args {
		err := ctx.compileAST(arg, false)
		if err != nil {
			return fmt.Errorf("error evaluating %q as argument %d in function %s: %v", astutil.ExprToString(arg), i+1, astutil.ExprToString(node.Fun), err)
		}
		err = ctx.maybeMaterialize(arg)
		if err != nil {
			return err
		}
		ctx.pushOp(&CallInjectionCopyArg{id: id, ArgNum: i, ArgExpr: arg})
	}

	ctx.pushOp(&CallInjectionComplete{id: id})

	return nil
}

// compileFunctionCallWithPinning compiles a function call when runtime.debugPinner
// is available in the target.
func (ctx *compileCtx) compileFunctionCallWithPinning(node *ast.CallExpr, id int, toplevel bool) error {
	if !toplevel {
		ctx.pinnerUsed = true

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Fix the failing argument per the wrapped cause: simplify it to a supported expression or use an existing variable
  2. Assign the complex expression to a temporary variable first ('set tmp = ...'), then 'call f(tmp)'
  3. Use a backend that supports pinning (native, non-stripped binary) if the argument requires literal allocation

Example fix

// before
(dlv) call f([]int{1,2})
// after
(dlv) set tmp = s // existing slice
(dlv) call f(tmp)
Defensive patterns

Strategy: validation

Validate before calling

// Validate each argument expression compiles standalone before the call
for i, arg := range args {
	if err := dryCompile(arg); err != nil {
		return fmt.Errorf("argument %d invalid before call: %v", i+1, err)
	}
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: 'call f(a, badExpr, c)' where the Nth argument fails compilation — e.g. an argument containing a composite literal (without pinning), an unsupported operator, or an unresolvable symbol.

Common situations: Calling functions whose arguments use unsupported expression syntax; passing literals/complex expressions on backends without pinning; typos in argument variable names.

Related errors


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