diff options
Diffstat (limited to 'src/reflect/all_test.go')
-rw-r--r-- | src/reflect/all_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index f9b2ffd4f1d..5df83bef7a3 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -6112,6 +6112,20 @@ func TestStructOfTooLarge(t *testing.T) { } } +func TestStructOfAnonymous(t *testing.T) { + var s any = struct{ D1 }{} + f := TypeOf(s).Field(0) + ds := StructOf([]StructField{f}) + st := TypeOf(s) + dt := New(ds).Elem() + if st != dt.Type() { + t.Errorf("StructOf returned %s, want %s", dt.Type(), st) + } + + // This should not panic. + _ = dt.Interface().(struct{ D1 }) +} + func TestChanOf(t *testing.T) { // check construction and use of type not in binary type T string |