]> Cypherpunks repositories - gostls13.git/commit
reflect: fix String of new array types
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 10 May 2017 11:10:46 +0000 (13:10 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 10 May 2017 11:42:46 +0000 (11:42 +0000)
commita4864094f0e5eb2369831f5e5b734b6398837712
treec6086174b65340461b66bfc0d333a795faa690a5
parent266a3b66ca1f49463a29f047d6fde62eb18025b8
reflect: fix String of new array types

When constructing a new type for an array type in ArrayOf, we don't
reset tflag to 0. All the other methods in the package, such as SliceOf,
do this already. This results in the new array type having weird issues
when being printed, such as having tflagExtraStar set when it shouldn't.

That flag removes the first char to get rid of '*', but when used
incorrectly in this case it eats the '[' character leading to broken
strings like "3]int".

This was fixed in 56752eb2 for issue #16722, but ArrayOf was missed.

Also make the XM test struct have a non-zero size as that leads to a
division by zero panic in ArrayOf.

Fixes #20311.

Change-Id: I18f1027fdbe9f71767201e7424269c3ceeb23eb5
Reviewed-on: https://go-review.googlesource.com/43130
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/reflect/all_test.go
src/reflect/type.go