Closed icholy closed 6 years ago
Syntax looks correct to me. This is a bug in the type-checker and I think I already know where to look. Will get to it as soon as I have a chance.
Here's a similar recursive type which panics when I try to compile.
package main
type A[T] struct {
Next *A[T]
}
func main() {
var a A[int]
a.Next = &a
}
edit: ^^ Pretty sure this is what's been killing your playground.
@icholy your first issue is fixed in 9d30a36bb82b8e43789f513810f4d64da50c2170. As I suspected, the problem was in types/predicates.go which defines rules for whether two types are assignable to one another.
After I added a missing type parameter, the playground example compiles 😄
@icholy your second example is actually a separate issue, so I moved it to #15.
@icholy the first half of the issue had to do with declarations failing in the type checker. The second half of the issue occurred when you actually tried to use the recursive generic type (it resulted in a stack overflow error when trying to generate the appropriate concrete type). It is now fixed in 02a4bdb70ec696af52a10d8bc71cb8ad6fa45dd3.
After a few changes, you can now actually use the Ring
type in your original playground example :)
Awesome!
What am I doing wrong here? https://play.folang.org/p/eFfTizZqyFQ