diff --git a/_test/struct7.go b/_test/struct7.go new file mode 100644 index 00000000..1caee308 --- /dev/null +++ b/_test/struct7.go @@ -0,0 +1,15 @@ +package main + +type Opt struct { + b bool +} + +type T struct { + i int + opt Opt +} + +func main() { + a := T{} + println(a.i, a.opt.b) +} diff --git a/interp/cfg.go b/interp/cfg.go index 3e912665..ea72a690 100644 --- a/interp/cfg.go +++ b/interp/cfg.go @@ -930,6 +930,7 @@ func (interp *Interpreter) Cfg(root *Node) []*Node { log.Println(n.index, "selector unresolved:", n.child[0].ident+"."+n.child[1].ident) } } else if fi := n.typ.fieldIndex(n.child[1].ident); fi >= 0 { + //log.Println(n.index, "selector field", fi) // Resolve struct field index if n.typ.cat == PtrT { n.run = getPtrIndex @@ -986,6 +987,9 @@ func (interp *Interpreter) Cfg(root *Node) []*Node { } n.typ = n.child[1].typ + case UnaryExpr: + wireChild(n) + case ValueSpec: l := len(n.child) - 1 if n.typ = n.child[l].typ; n.typ == nil {