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
The protoreflect.Message interface documentation does not specify how mutabilty of protoreflect.Value for Message, List and Map types works when Getting them or Setting them.
For example, something that I found inconsistent was the fact that if you Set a MapValue or MessageValue and you modify it after, the changes are reflected in the message, this does not appear to be the case for ListValue.
The text was updated successfully, but these errors were encountered:
We're missing a line of documentation on Message.Set. List.Set, List.Append, and Map.Set all state:
// When setting a composite type, it is unspecified whether the set// value aliases the source's memory in any way.
Message.Set should have the same text.
In addition, it would be good to have a clear description of aliasing behavior somewhere. The summary is that a protoreflect.Value acquired from a composite value's Get or Mutable method is guaranteed to alias the original value, and that it is otherwise unspecified when aliasing occurs.
So this is a valid way to append to a repeated field:
list:=m.Mutable(someRepeatedFieldDesc).List()
list.Append(v) // appends v to the field in m
But this is not:
list := m.NewField(someRepeatedFieldDesc).List()
m.Set(someRepeatedFieldDesc, list)
// It is unspecified whether `list` aliases the field in `m`,
// so the next line may or may not modify m.
list.Append(v)
The
protoreflect.Message
interface documentation does not specify how mutabilty ofprotoreflect.Value
forMessage
,List
andMap
types works whenGet
ting them orSet
ting them.For example, something that I found inconsistent was the fact that if you
Set
aMapValue
orMessageValue
and you modify it after, the changes are reflected in the message, this does not appear to be the case forListValue
.The text was updated successfully, but these errors were encountered: