From effd64c980bbd55df4d356918047f23ff4e82d31 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 24 Sep 2019 16:10:04 +0200 Subject: [PATCH] fix: handle forward declaration of alias type --- _test/alias1.go | 16 ++++++++++++++++ interp/gta.go | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 _test/alias1.go diff --git a/_test/alias1.go b/_test/alias1.go new file mode 100644 index 000000000..83f134263 --- /dev/null +++ b/_test/alias1.go @@ -0,0 +1,16 @@ +package main + +import "fmt" + +type MyT T + +type T struct { + Name string +} + +func main() { + fmt.Println(MyT{}) +} + +// Output: +// {} diff --git a/interp/gta.go b/interp/gta.go index aa75a4da8..8d3b5b251 100644 --- a/interp/gta.go +++ b/interp/gta.go @@ -165,7 +165,7 @@ func (interp *Interpreter) gta(root *node, rpath string) ([]*node, error) { return false } if n.child[1].kind == identExpr { - n.typ = &itype{cat: aliasT, val: typ, name: typeName, path: rpath} + n.typ = &itype{cat: aliasT, val: typ, name: typeName, path: rpath, incomplete: typ.incomplete} } else { n.typ = typ n.typ.name = typeName