interp: avoid panic in output value generation for recursive types
Fixes #1134.
This commit is contained in:
20
_test/issue-1134.go
Normal file
20
_test/issue-1134.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
type I interface {
|
||||
Hello()
|
||||
}
|
||||
|
||||
type T struct {
|
||||
Name string
|
||||
Child []*T
|
||||
}
|
||||
|
||||
func (t *T) Hello() { println("Hello", t.Name) }
|
||||
|
||||
func main() {
|
||||
var i I = new(T)
|
||||
i.Hello()
|
||||
}
|
||||
|
||||
// Output:
|
||||
// Hello
|
||||
@@ -350,7 +350,7 @@ func genValueOutput(n *node, t reflect.Type) func(*frame) reflect.Value {
|
||||
}
|
||||
fallthrough
|
||||
case n.anc.kind == returnStmt && n.anc.val.(*node).typ.ret[0].cat == interfaceT:
|
||||
if len(n.anc.val.(*node).typ.ret[0].field) == 0 {
|
||||
if nod, ok := n.anc.val.(*node); !ok || len(nod.typ.ret[0].field) == 0 {
|
||||
// empty interface, do not wrap
|
||||
return value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user