You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While map elements are not themselves addressable, if the element is a pointer the pointee should be modifiable directly via map access as shown in this playground snippet.
gomacro> import "reflect" // Just a package with a handy struct.
gomacro> m := make(map[string]*reflect.SliceHeader)
gomacro> m["a"] = &reflect.SliceHeader{}
gomacro> m["a"].Len = 2
repl.go:1:1: cannot assign to m["a"].Len
repl.go:1:1: cannot take the address of a map element: m["a"]
The text was updated successfully, but these errors were encountered:
The problem is not limited to maps - it happens with all syntaxes that return non-settable values which happen to be pointers. Another example:
gomacro> import "reflect"
gomacro> func header() *reflect.SliceHeader { return &reflect.SliceHeader{} }
gomacro> header().Len
0 // int
gomacro> header().Len = 2
repl.go:1:1: cannot assign to header().Len
repl.go:1:1: cannot take the address of: header()
If you want to give a shot at it, I guess the problem is due to gomacro/fast/assignment.go method
(*Comp).placeOrAddress() not realizing that the implicit pointer dereference makes the expression addressable and settable.
Otherwise, I will probably be able to investigate it in 1-2 weeks (real life struck)
While map elements are not themselves addressable, if the element is a pointer the pointee should be modifiable directly via map access as shown in this playground snippet.
The text was updated successfully, but these errors were encountered: