From a67bce4b48c56d049c26853946dce60009dd0abf Mon Sep 17 00:00:00 2001 From: "ajeffrey@roblox.com" Date: Fri, 7 Jan 2022 11:36:16 -0600 Subject: [PATCH] Added example of exponential blowup --- rfcs/recursive-type-unrestriction.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rfcs/recursive-type-unrestriction.md b/rfcs/recursive-type-unrestriction.md index 05dab4aa..9581d7f0 100644 --- a/rfcs/recursive-type-unrestriction.md +++ b/rfcs/recursive-type-unrestriction.md @@ -124,7 +124,7 @@ producing unbounded type graphs during unification. ### Strict recursive type instantiations with a cache and an occurrence check -We can use occurrence checks to ensure there's no blowup. We can restrict +We can use occurrence checks to ensure there's less blowup. We can restrict a recursive use `T` in the definition of `T` so that either `UI` is `aI` or contains none of `a1...aN`. For example this bans ``` @@ -139,4 +139,14 @@ since `a` is not `b`, but allows: type T = { foo: T? } ``` +This still has exponential blowup, for example +```lua +type T = { + p1: T, + p2: T, + ... + pN: T, +} +``` + *Advantages*: types are computed strictly, and may produce better error messages if the occurs check fails.