mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Added example of exponential blowup
This commit is contained in:
parent
92a90ee7b5
commit
a67bce4b48
1 changed files with 11 additions and 1 deletions
|
@ -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<U1,...,UN>` in the definition of `T<a1...aN>` 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<a,b> = { foo: T<a,number>? }
|
||||
```
|
||||
|
||||
This still has exponential blowup, for example
|
||||
```lua
|
||||
type T<a1,a2,a3,...,aN> = {
|
||||
p1: T<number, a2, a3, ..., aN>,
|
||||
p2: T<a1, number, a3, ..., aN>,
|
||||
...
|
||||
pN: T<a1, a2, a3, ..., number>,
|
||||
}
|
||||
```
|
||||
|
||||
*Advantages*: types are computed strictly, and may produce better error messages if the occurs check fails.
|
||||
|
|
Loading…
Add table
Reference in a new issue