reflect; SetLen() requires an addressable value
Этот коммит содержится в:
родитель
4d43df75d5
коммит
17f5fb1071
2 изменённых файлов: 3 добавлений и 1 удалений
|
@ -999,7 +999,7 @@ func (v Value) SetLen(n int) {
|
|||
if v.typecode.Kind() != Slice {
|
||||
panic(&ValueError{Method: "reflect.Value.SetLen", Kind: v.Kind()})
|
||||
}
|
||||
|
||||
v.checkAddressable()
|
||||
hdr := (*sliceHeader)(v.value)
|
||||
if int(uintptr(n)) != n || uintptr(n) > hdr.cap {
|
||||
panic("reflect.Value.SetLen: slice length out of range")
|
||||
|
|
|
@ -180,6 +180,8 @@ func TestSlice(t *testing.T) {
|
|||
}
|
||||
|
||||
// should be equivalent to s28 now, except for the capacity which doesn't change
|
||||
|
||||
s268ref = ValueOf(&s268).Elem()
|
||||
s268ref.SetLen(6)
|
||||
if len(s28) != s268ref.Len() || cap(s268) != s268ref.Cap() {
|
||||
t.Errorf("SetLen: len(s268)=%d s268ref.Len()=%d cap(s268)=%d s268ref.Cap()=%d\n", len(s28), s268ref.Len(), cap(s268), s268ref.Cap())
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче