fix: substitute recursive struct type by interface{} in function arguments
This commit is contained in:
24
_test/struct38.go
Normal file
24
_test/struct38.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
type T struct {
|
||||
f func(t *T1)
|
||||
y *xxx
|
||||
}
|
||||
|
||||
type T1 struct {
|
||||
T
|
||||
}
|
||||
|
||||
type xxx struct{}
|
||||
|
||||
var (
|
||||
x1 *T1 = x
|
||||
x = &T1{}
|
||||
)
|
||||
|
||||
func main() {
|
||||
println("ok")
|
||||
}
|
||||
|
||||
// Output:
|
||||
// ok
|
||||
@@ -1,8 +1,6 @@
|
||||
package interp
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
import "reflect"
|
||||
|
||||
// gta performs a global types analysis on the AST, registering types,
|
||||
// variables and functions symbols at package level, prior to CFG.
|
||||
|
||||
@@ -905,6 +905,9 @@ var interf = reflect.TypeOf(new(interface{})).Elem()
|
||||
|
||||
func (t *itype) refType(defined map[string]*itype, wrapRecursive bool) reflect.Type {
|
||||
if t.rtype != nil {
|
||||
if wrapRecursive && t.cat == structT && defined[t.name] != nil {
|
||||
return interf
|
||||
}
|
||||
return t.rtype
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user