Skip to content

Commit

Permalink
fix: handle forward declaration for aliased type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes committed Apr 22, 2020
1 parent 7b2d91b commit 71f730b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions _test/type22.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

type T1 T

func foo() T1 {
return T1(T{"foo"})
}

type T struct {
Name string
}

func main() {
println(foo().Name)
}
2 changes: 1 addition & 1 deletion interp/gta.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (interp *Interpreter) gta(root *node, rpath, pkgID string) ([]*node, error)
return false
}
if n.child[1].kind == identExpr {
n.typ = &itype{cat: aliasT, val: typ, name: typeName, path: rpath, field: typ.field, incomplete: typ.incomplete, scope: sc}
n.typ = &itype{cat: aliasT, val: typ, name: typeName, path: rpath, field: typ.field, incomplete: typ.incomplete, scope: sc, node: n.child[0]}
copy(n.typ.method, typ.method)
} else {
n.typ = typ
Expand Down

0 comments on commit 71f730b

Please sign in to comment.