]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: clear tflag for StructOf type
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 3 Jun 2016 15:27:33 +0000 (11:27 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 3 Jun 2016 19:01:03 +0000 (19:01 +0000)
Fixes #15923

Change-Id: I3e56564365086ceb0bfc15db61db6fb446ab7448
Reviewed-on: https://go-review.googlesource.com/23760
Reviewed-by: Sebastien Binet <seb.binet@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/reflect/all_test.go
src/reflect/type.go

index f7cf46daecf524b278e6fd60a0e4d5e4f8bffb4f..97086b1852fbba6a38d7e09b139b4cddcfca9ddd 100644 (file)
@@ -3934,6 +3934,10 @@ func TestStructOf(t *testing.T) {
        if s != want {
                t.Errorf("constructed struct = %s, want %s", s, want)
        }
+       const stStr = `struct { S string "s"; X uint8 "x"; Y uint64; Z [3]uint16 }`
+       if got, want := st.String(), stStr; got != want {
+               t.Errorf("StructOf(fields).String()=%q, want %q", got, want)
+       }
 
        // check the size, alignment and field offsets
        stt := TypeOf(struct {
index c9e14707fa8ef7db97634bc466b7c32347896f10..b70887fbba0f5e2b215664cb9d357a22fa5e98c7 100644 (file)
@@ -2640,6 +2640,7 @@ func StructOf(fields []StructField) Type {
        }
 
        typ.str = resolveReflectName(newName(str, "", "", false))
+       typ.tflag = 0
        typ.hash = hash
        typ.size = size
        typ.align = typalign