{"record":{"id":"fc34fb40c687396f","repo":"go-delve/delve","slug":"allocating-a-literal-of-type-s-not-implemented","errorCode":null,"errorMessage":"allocating a literal of type %s not implemented","messagePattern":"allocating a literal of type (.+?) not implemented","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/evalop/evalcompile.go","lineNumber":882,"sourceCode":"\t\tctx.pushOp(&TypeCast{\n\t\t\tDwarfType: godwarf.FakePointerType(dtyp, int64(ctx.PtrSize())),\n\t\t\tNode: &ast.CallExpr{\n\t\t\t\tFun:  lit.Type,\n\t\t\t\tArgs: []ast.Expr{&ast.Ident{Name: \"new allocation\"}}}})\n\n\t\txderef := &ast.StarExpr{X: &ast.Ident{Name: \"new-allocation\"}}\n\t\txset := &ast.Ident{Name: \"literal-allocation\"}\n\n\t\tctx.pushOp(&Dup{})                // stack after: [ ptrToRealLiteral, ptrToRealLiteral, fakeLiteral ]\n\t\tctx.pushOp(&PointerDeref{xderef}) // stack after: [ realLiteral, ptrToRealLiteral, fakeLiteral ]\n\t\tctx.pushOp(&Roll{2})              // stack after: [ fakeLiteral, realLiteral, ptrToRealLiteral ]\n\t\tctx.pushOp(&Roll{1})              // stack after: [ realLiteral, fakeLiteral, ptrToRealLiteral ]\n\t\tctx.pushOp(&SetValue{Rhe: xset})  // stack after: [ ptrToRealLiteral ]\n\t\treturn nil\n\n\tdefault:\n\t\t// either *godwarf.MapType, *godwarf.SliceType or *godwarf.FuncType\n\t\treturn fmt.Errorf(\"allocating a literal of type %s not implemented\", dtyp.String())\n\t}\n\n}\n\nfunc Listing(depth []int, ops []Op) string {\n\tif depth == nil {\n\t\tdepth = make([]int, len(ops)+1)\n\t}\n\tbuf := new(strings.Builder)\n\tfor i, op := range ops {\n\t\tfmt.Fprintf(buf, \" %3d  (%2d->%2d) %#v\\n\", i, depth[i], depth[i+1], op)\n\t}\n\treturn buf.String()\n}\n\nfunc isStringLiteralThatNeedsAlloc(expr ast.Expr) bool {\n\tswitch expr := expr.(type) {\n\tcase *ast.BasicLit:","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/evalop/evalcompile.go#L864-L900","documentation":"maybeMaterialize allocates real storage in the debuggee for literal values produced by compiled expressions (so they can be assigned or passed by reference). The default case — MapType, SliceType, or FuncType literals — is not implemented, so it errors with 'allocating a literal of type %s not implemented'. Assignment (set) or call arguments whose literal has one of these types cannot be materialized.","triggerScenarios":"'set m = map[string]int{...}' or passing a map/slice/func literal as a call argument; any path where CompileSet, compileAST, or a function-call compile needs to materialize a map/slice/func-typed literal.","commonSituations":"Trying to assign a whole new map or slice literal to a variable at the (dlv) prompt; attempting 'set f = someFunc' style reassignment of function values; IDE set-value actions on composite literals.","solutions":["Mutate in place instead of assigning a new literal: 'set m[\"k\"] = v' or 'set s[0] = x'","Populate via a program function using call injection: define/look for a constructor in the debuggee and 'call makeMap(...)',' or write the assignment in the source code and re-run","Avoid reassigning function values; set them in source and restart the debug session"],"exampleFix":"// before\n(dlv) set m = map[string]int{\"a\": 1}\n// after\n(dlv) set m[\"a\"] = 1 // mutate existing map","handlingStrategy":"fallback","validationCode":"// Detect literal assignment to map/slice/func types and fall back to mutation\nif strings.Contains(expr, \"=\") && (strings.Contains(expr, \"map[\") || strings.Contains(expr, \"[]\") || strings.Contains(expr, \"func\")) {\n\t// plan element-wise mutation instead of whole-literal assignment\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Mutate maps/slices element-wise instead of assigning new literals","Add a constructor function in the program and use call","Reassign such values in source and re-run"],"tags":["debugger","expression-evaluation","set"],"backgroundTag":"unsupported-literal-allocation","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}