Skip to content

Commit 9cd6e2c

Browse files
committed
Add name type for anon struct
1 parent 23d52b6 commit 9cd6e2c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ func (p *parser) fromStruct(t reflect.Type) typesTable {
172172
for name, typ := range p.fromStruct(f.Type) {
173173
types[name] = typ
174174
}
175-
} else {
176-
types[f.Name] = f.Type
177175
}
176+
177+
types[f.Name] = f.Type
178178
}
179179
}
180180

parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func TestParser_createTypesTable(t *testing.T) {
233233
p := parser{}
234234
types := p.createTypesTable(A{})
235235

236-
if len(types) != 2 {
236+
if len(types) != 5 {
237237
t.Error("unexpected number of fields")
238238
}
239239
if types["F"] != intType {

type_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ var typeTests = []typeTest{
7474
"Int % Int > 1",
7575
"Int in Int..Int",
7676
"EmbStr == ''",
77+
"Embedded.EmbStr",
7778
"EmbPtrStr == ''",
79+
"EmbeddedPtr ~ Str",
7880
"SubStr ~ ''",
81+
"SubEmbedded.SubStr",
7982
"OkFn() and OkFn()",
8083
"Foo.Fn() or Foo.Fn()",
8184
}
@@ -281,10 +284,6 @@ var typeErrorTests = []typeErrorTest{
281284
"1 in Foo",
282285
"invalid operation: 1 in Foo (mismatched types float64 and *expr_test.foo)",
283286
},
284-
{
285-
"Embedded.EmbStr ~ Str",
286-
"unknown name Embedded",
287-
},
288287
}
289288

290289
type abc interface {

0 commit comments

Comments
 (0)