{"record":{"id":"d0410816f386c4f1","repo":"go-delve/delve","slug":"error-evaluating-q-as-argument-d-in-function-s","errorCode":null,"errorMessage":"error evaluating %q as argument %d in function %s: %v","messagePattern":"error evaluating %q as argument (.+?) in function (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":749,"sourceCode":"\tif hasFunc {\n\t\tjmpif = &Jump{When: JumpIfFalse, Pop: true}\n\t\tctx.pushOp(jmpif)\n\t}\n\tctx.pushOp(&Pop{})\n\terr = ctx.compileAST(node.Fun, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif jmpif != nil {\n\t\tjmpif.Target = len(ctx.ops)\n\t}\n\n\tctx.pushOp(&CallInjectionSetTarget{id: id})\n\n\tfor i, arg := range node.Args {\n\t\terr := ctx.compileAST(arg, false)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error evaluating %q as argument %d in function %s: %v\", astutil.ExprToString(arg), i+1, astutil.ExprToString(node.Fun), err)\n\t\t}\n\t\terr = ctx.maybeMaterialize(arg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tctx.pushOp(&CallInjectionCopyArg{id: id, ArgNum: i, ArgExpr: arg})\n\t}\n\n\tctx.pushOp(&CallInjectionComplete{id: id})\n\n\treturn nil\n}\n\n// compileFunctionCallWithPinning compiles a function call when runtime.debugPinner\n// is available in the target.\nfunc (ctx *compileCtx) compileFunctionCallWithPinning(node *ast.CallExpr, id int, toplevel bool) error {\n\tif !toplevel {\n\t\tctx.pinnerUsed = true","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L731-L767","documentation":"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.","triggerScenarios":"'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.","commonSituations":"Calling functions whose arguments use unsupported expression syntax; passing literals/complex expressions on backends without pinning; typos in argument variable names.","solutions":["Fix the failing argument per the wrapped cause: simplify it to a supported expression or use an existing variable","Assign the complex expression to a temporary variable first ('set tmp = ...'), then 'call f(tmp)'","Use a backend that supports pinning (native, non-stripped binary) if the argument requires literal allocation"],"exampleFix":"// before\n(dlv) call f([]int{1,2})\n// after\n(dlv) set tmp = s // existing slice\n(dlv) call f(tmp)","handlingStrategy":"validation","validationCode":"// Validate each argument expression compiles standalone before the call\nfor i, arg := range args {\n\tif err := dryCompile(arg); err != nil {\n\t\treturn fmt.Errorf(\"argument %d invalid before call: %v\", i+1, err)\n\t}\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use plain variables as call arguments","Materialize complex values with set first","Prefer a pinning-capable (native) backend for call injection"],"tags":["debugger","function-call","expression-evaluation"],"backgroundTag":"argument-evaluation-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}