-
What does this error message mean? Why does it happen type Foo<T> = {a: Foo<number>, b: T}
type Bar<T> = Foo<Foo<T>> -- TypeError: recursive type being used with different parameters Is this restriction in order to avoid non-contractive types? The reason that I'm asking is that I'm working on a type checker for Erlang, which also has expressive generic aliases and untagged unions. I'm really impressed with Luau's type aliases and wonder how you got so much expressivity without infinite loops in the checker like racket/typed-racket#1130 and josefs/Gradualizer#322. Most languages don't accept definitions like the following, which luau accepts: type Tree<T> =
{}
| Children<Tree<T>>
type Children<T> = {left: T, right: T} Beautiful language, thanks for open-sourcing! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is a side-effect of https://github.com/Roblox/luau/blob/master/rfcs/recursive-type-restriction.md. We introduced this to keep generic types from expanding indefinitely during generic argument substitution. @asajeffrey was looking into whether we can make the restriction a bit more lenient without introducing issues for type checker, see #86 (which is still a draft for now) |
Beta Was this translation helpful? Give feedback.
This is a side-effect of https://github.com/Roblox/luau/blob/master/rfcs/recursive-type-restriction.md. We introduced this to keep generic types from expanding indefinitely during generic argument substitution. @asajeffrey was looking into whether we can make the restriction a bit more lenient without introducing issues for type checker, see #86 (which is still a draft for now)