Skip to content

Commit 023c3d4

Browse files
compiler: omit field name for embedded fields in reflection string
This matches the gc compiler. The test case was sent for the master repo as https://golang.org/cl/91138. Fixes golang/go#23620 Change-Id: Ibdda1ae9b23eab61b1d35ec4f87638462a6ec1db Reviewed-on: https://go-review.googlesource.com/91139 Reviewed-by: Than McIntosh <thanm@google.com>
1 parent b833695 commit 023c3d4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

go/types.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6417,11 +6417,11 @@ Struct_type::do_reflection(Gogo* gogo, std::string* ret) const
64176417
if (p != this->fields_->begin())
64186418
ret->push_back(';');
64196419
ret->push_back(' ');
6420-
if (p->is_anonymous())
6421-
ret->push_back('?');
6422-
else
6423-
ret->append(Gogo::unpack_hidden_name(p->field_name()));
6424-
ret->push_back(' ');
6420+
if (!p->is_anonymous())
6421+
{
6422+
ret->append(Gogo::unpack_hidden_name(p->field_name()));
6423+
ret->push_back(' ');
6424+
}
64256425
if (p->is_anonymous()
64266426
&& p->type()->named_type() != NULL
64276427
&& p->type()->named_type()->is_alias())

libgo/go/reflect/all_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ var typeTests = []pair{
170170
}{},
171171
"interface { reflect_test.a(func(func(int) int) func(func(int)) int); reflect_test.b() }",
172172
},
173+
{struct {
174+
x struct {
175+
int32
176+
int64
177+
}
178+
}{},
179+
"struct { int32; int64 }",
180+
},
173181
}
174182

175183
var valueTests = []pair{

0 commit comments

Comments
 (0)