diff --git a/_test/fun11.go b/_test/fun11.go new file mode 100644 index 000000000..a7e1fd2b7 --- /dev/null +++ b/_test/fun11.go @@ -0,0 +1,12 @@ +package main + +var f F + +type F func(int) + +func main() { + println("ok") +} + +// Output: +// ok diff --git a/interp/gta.go b/interp/gta.go index 3f2441953..38eff35f5 100644 --- a/interp/gta.go +++ b/interp/gta.go @@ -52,7 +52,7 @@ func (interp *Interpreter) gta(root *node, rpath, pkgID string) ([]*node, error) val = src.rval } if typ.incomplete { - // Come back when type is known + // Come back when type is known. revisit = append(revisit, n) return false } @@ -80,6 +80,11 @@ func (interp *Interpreter) gta(root *node, rpath, pkgID string) ([]*node, error) if n.typ, err = nodeType(interp, sc, n.child[l]); err != nil { return false } + if n.typ.incomplete { + // Come back when type is known. + revisit = append(revisit, n) + return false + } } for _, c := range n.child[:l] { sc.sym[c.ident] = &symbol{index: sc.add(n.typ), kind: varSym, global: true, typ: n.typ}