I have a encountered an issue when trying to get the whole type name as string of a generic type and I was able to create a small example to reproduce it.
When running the code in standard Go, the program prints: Herd[main.Wolf] , however, with TinyGo, it prints Herd omitting the type parameter of the generic struct:
Env: tinygo version 0.30.0 darwin/amd64 (using go version go1.21.6 and LLVM version 16.0.1)
tinygo run -target=wasi main.go
package main
import "reflect"
type Animal interface {
sound()
}
type Wolf struct{}
func (w Wolf) sound() {}
type Herd[T Animal] struct{}
func main() {
wolvesHerd := Herd[Wolf]{}
herdVal := reflect.ValueOf(wolvesHerd)
typeName := herdVal.Type().Name()
println(typeName)
}
We "just" need to include the TypeParams when constructing the data field in compiler/interface.go, and then pull it out correctly in src/reflect/type.go.
I have a encountered an issue when trying to get the whole type name as string of a generic type and I was able to create a small example to reproduce it. When running the code in standard Go, the program prints: Herd[main.Wolf] , however, with TinyGo, it prints Herd omitting the type parameter of the generic struct:
Env:
tinygo version 0.30.0 darwin/amd64 (using go version go1.21.6 and LLVM version 16.0.1)
tinygo run -target=wasi main.go