From 5de90d33c837af4d9a375a0a36811c7033655596 Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Wed, 1 Jul 2020 11:31:15 +0000 Subject: Revert "encoding/json: don't reuse slice elements when decoding" This reverts https://golang.org/cl/191783. Reason for revert: Broke too many programs which depended on the previous behavior, even when it was the opposite of what the documentation said. We can attempt to fix the original issue again for 1.16, while keeping those programs in mind. Fixes #39427. Change-Id: I7a7f24b2a594c597ef625aeff04fff29aaa88fc6 Reviewed-on: https://go-review.googlesource.com/c/go/+/240657 Run-TryBot: Dmitri Shuralyov TryBot-Result: Gobot Gobot Reviewed-by: Emmanuel Odeke Reviewed-by: Ian Lance Taylor --- src/encoding/json/decode_test.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/encoding/json/decode_test.go') diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index 2728c8ee50..219e845c7b 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -2099,10 +2099,7 @@ func TestSkipArrayObjects(t *testing.T) { // slices, and arrays. // Issues 4900 and 8837, among others. func TestPrefilled(t *testing.T) { - type T struct { - A, B int - } - // Values here change, cannot reuse the table across runs. + // Values here change, cannot reuse table across runs. var prefillTests = []struct { in string ptr interface{} @@ -2138,16 +2135,6 @@ func TestPrefilled(t *testing.T) { ptr: &[...]int{1, 2}, out: &[...]int{3, 0}, }, - { - in: `[{"A": 3}]`, - ptr: &[]T{{A: -1, B: -2}, {A: -3, B: -4}}, - out: &[]T{{A: 3}}, - }, - { - in: `[{"A": 3}]`, - ptr: &[...]T{{A: -1, B: -2}, {A: -3, B: -4}}, - out: &[...]T{{A: 3, B: -2}, {}}, - }, } for _, tt := range prefillTests { -- cgit v1.3