{"record":{"id":"471174436197a804","repo":"go-delve/delve","slug":"literal-can-not-be-allocated-because-function-call","errorCode":null,"errorMessage":"literal can not be allocated because function calls are not allowed without using 'call'","messagePattern":"literal can not be allocated because function calls are not allowed without using 'call'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":21,"sourceCode":"import (\n\t\"errors\"\n\t\"fmt\"\n\t\"go/ast\"\n\t\"go/constant\"\n\t\"go/parser\"\n\t\"go/scanner\"\n\t\"go/token\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/go-delve/delve/pkg/astutil\"\n\t\"github.com/go-delve/delve/pkg/dwarf/godwarf\"\n\t\"github.com/go-delve/delve/pkg/dwarf/reader\"\n)\n\nvar (\n\tErrFuncCallNotAllowed         = errors.New(\"function calls not allowed without using 'call'\")\n\terrFuncCallNotAllowedLitAlloc = errors.New(\"literal can not be allocated because function calls are not allowed without using 'call'\")\n)\n\nconst (\n\tDelvePackage                       = \"delve\"\n\tBreakpointHitCountVarName          = \"bphitcount\"\n\tBreakpointHitCountVarNameQualified = DelvePackage + \".\" + BreakpointHitCountVarName\n\tDebugPinnerFunctionName            = \"runtime.debugPinnerV1\"\n)\n\ntype compileCtx struct {\n\tevalLookup\n\tops        []Op\n\tallowCalls bool\n\tcurCall    int\n\tflags      Flags\n\tpinnerUsed bool\n\thasCalls   bool\n}","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L3-L39","documentation":"errFuncCallNotAllowedLitAlloc is the literal-allocation variant of ErrFuncCallNotAllowed: allocating a composite/string literal in the target process requires function calls, and the expression was compiled with calls disallowed. It is returned by compileAST in pkg/proc/evalop/evalcompile.go when a literal must be allocated at runtime but call injection is off.","triggerScenarios":"Evaluating an expression containing a composite or string literal that must be allocated in the target (e.g. printing a newly constructed struct/slice literal) while using a non-'call' evaluation path.","commonSituations":"print of expressions like []int{1,2,3} or map[string]int{...} through an API that disallows calls; conditional breakpoint expressions containing literal allocation; confusion between print and call semantics.","solutions":["Use the 'call' command (or EvalExpressionWithCalls API) so literal allocation is permitted","Rewrite the expression to avoid runtime allocation, e.g. inspect existing variables instead of constructing new ones","Assign the literal to a variable in the debugged program first, then print that variable"],"exampleFix":"// before\ndlv> print []string{\"a\", \"b\"}\n// after\ndlv> call f([]string{\"a\", \"b\"})","handlingStrategy":"validation","validationCode":"// avoid literals requiring allocation when calls are disallowed\n// rewrite []int{1,2,3} expressions or route them through EvalExpressionWithCalls","typeGuard":null,"tryCatchPattern":"if errors.Is(err, evalop.ErrFuncCallNotAllowed) {\n    // fall back: inspect existing variables instead of allocating literals\n}","preventionTips":["Don't construct composite/string literals in non-'call' evaluations","Pre-allocate test data in the debugged program and print the variable","Route literal-bearing expressions through the 'call' command"],"tags":["go","function-call","literal","eval"],"backgroundTag":"func-call-not-allowed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}