File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -6112,6 +6112,20 @@ func TestStructOfTooLarge(t *testing.T) {
6112
6112
}
6113
6113
}
6114
6114
6115
+ func TestStructOfAnonymous (t * testing.T ) {
6116
+ var s any = struct { D1 }{}
6117
+ f := TypeOf (s ).Field (0 )
6118
+ ds := StructOf ([]StructField {f })
6119
+ st := TypeOf (s )
6120
+ dt := New (ds ).Elem ()
6121
+ if st != dt .Type () {
6122
+ t .Errorf ("StructOf returned %s, want %s" , dt .Type (), st )
6123
+ }
6124
+
6125
+ // This should not panic.
6126
+ _ = dt .Interface ().(struct { D1 })
6127
+ }
6128
+
6115
6129
func TestChanOf (t * testing.T ) {
6116
6130
// check construction and use of type not in binary
6117
6131
type T string
Original file line number Diff line number Diff line change @@ -2287,8 +2287,9 @@ func StructOf(fields []StructField) Type {
2287
2287
// Update string and hash
2288
2288
name := f .Name .Name ()
2289
2289
hash = fnv1 (hash , []byte (name )... )
2290
- repr = append (repr , (" " + name )... )
2291
- if f .Embedded () {
2290
+ if ! f .Embedded () {
2291
+ repr = append (repr , (" " + name )... )
2292
+ } else {
2292
2293
// Embedded field
2293
2294
if f .Typ .Kind () == abi .Pointer {
2294
2295
// Embedded ** and *interface{} are illegal
You can’t perform that action at this time.
0 commit comments