{"record":{"id":"6bcb1cddcfe81425","repo":"go-delve/delve","slug":"can-not-set-variables-of-type-s-not-implemented","errorCode":null,"errorMessage":"can not set variables of type %s (not implemented)","messagePattern":"can not set variables of type (.+?) \\(not implemented\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":692,"sourceCode":"\t}\n\n\t// slice assignment (this is not handled by the writeCopy below so that\n\t// results of a reslice operation can be used here).\n\tif srcv.Kind == reflect.Slice {\n\t\treturn dstv.writeSlice(srcv.Len, srcv.Cap, srcv.Base)\n\t}\n\n\t// allow any integer to be converted to any pointer\n\tif t, isptr := dstv.RealType.(*godwarf.PtrType); isptr {\n\t\treturn dstv.writeUint(srcv.Children[0].Addr, t.ByteSize)\n\t}\n\n\t// byte-by-byte copying for everything else, but the source must be addressable\n\tif srcv.Addr != 0 {\n\t\treturn dstv.writeCopy(srcv)\n\t}\n\n\treturn fmt.Errorf(\"can not set variables of type %s (not implemented)\", dstv.Kind.String())\n}\n\n// SetVariable sets the value of the named variable\nfunc (scope *EvalScope) SetVariable(name, value string) error {\n\tops, err := evalop.CompileSet(scopeToEvalLookup{scope}, name, value, scope.evalopFlags())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstack := &evalStack{}\n\tstack.eval(scope, ops)\n\t_, err = stack.result(nil)\n\treturn err\n}\n\n// LocalVariables returns all local variables from the current function scope.\nfunc (scope *EvalScope) LocalVariables(cfg LoadConfig) ([]*Variable, error) {\n\tvars, err := scope.Locals(0, \"\")","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L674-L710","documentation":"setValue falls back to byte-by-byte copy only when the source variable is addressable (srcv.Addr != 0). If none of the special cases (numerics, strings, slices, nil, pointers, copy) apply and the source has no address, the assignment is not implemented for this kind and this error is returned. It signals an unsupported assignment shape rather than invalid input.","triggerScenarios":"SetVariable or call-injection argument copy where the source value is a non-addressable constant/intermediate result of a kind not handled by the numeric/string/slice/pointer fast paths (dstv.Kind reported in the message, e.g. struct, chan, map, interface), so writeCopy cannot be used.","commonSituations":"Assigning a literal struct or composite expression to a struct variable; assigning the result of an expression (e.g. `x = <-ch`, `x = someFunc()` for chan/struct kinds); copying from a register-resident optimized value with no memory address; call injection passing a temporary struct constant as an argument.","solutions":["Assign a value that lives in memory: first store the source into an addressable variable (e.g. a temporary global or an existing variable) and copy from it.","Break composite assignments into per-field assignments: set each field of the struct individually.","For call injection, pass addressable arguments (variables) rather than composite literal expressions.","If a kind you believe should work triggers this, it may warrant an upstream feature request; meanwhile compute the value in the debuggee via a call injection (e.g. inject a setter function)."],"exampleFix":"// before\nscope.SetVariable(\"s\", \"struct{T int}{T: 42}\") // can not set variables of type struct (not implemented)\n// after\nscope.SetVariable(\"s.T\", \"42\") // assign fields individually","handlingStrategy":"validation","validationCode":"src, err := scope.EvalExpression(value, loadSingleValue)\nif err != nil { return err }\nif src.Addr == 0 && src.Kind != reflect.Basic {\n    return fmt.Errorf(\"value %q is non-addressable of kind %s; assign fields or an addressable variable instead\", value, src.Kind)\n}","typeGuard":"func isAddressable(v *proc.Variable) bool { return v != nil && v.Addr != 0 }","tryCatchPattern":"if err := scope.SetVariable(name, value); err != nil {\n    if strings.Contains(err.Error(), \"not implemented\") {\n        return fmt.Errorf(\"assignment of %q unsupported for kind reported; assign per-field instead\", value)\n    }\n    return err\n}","preventionTips":["Assign scalar literals or other addressable variables, not composite literal expressions","Set struct fields individually (s.f = x) rather than whole structs","For call injection, pass addressable variables as arguments","When a value has no memory location (register/constant), copy it into an addressable holder first"],"tags":["go","debugger","set-variable","unsupported-kind"],"backgroundTag":"assignment-not-implemented","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}