reflect: another obscure RO bug

This commit is contained in:
Damian Gryski
2023-03-30 13:50:50 -07:00
committed by Ron Evans
parent b39a982067
commit e6ccdd9d1a
+3 -1
View File
@@ -276,7 +276,9 @@ func (v Value) Addr() Value {
if !v.CanAddr() {
panic("reflect.Value.Addr of unaddressable value")
}
flags := (v.flags & (valueFlagExported)) | v.flags.ro()
// Preserve flagRO instead of using v.flag.ro() so that
// v.Addr().Elem() is equivalent to v (#32772)
flags := v.flags & (valueFlagExported | valueFlagRO)
return Value{
typecode: pointerTo(v.typecode),
value: v.value,