Skip to content

Commit

Permalink
fix: substitute recursive struct type by interface{} in function argu…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
mvertes committed Mar 19, 2020
1 parent daaeac6 commit b52dd8c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
24 changes: 24 additions & 0 deletions _test/struct38.go
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions interp/gta.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 3 additions & 0 deletions interp/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b52dd8c

Please sign in to comment.