mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-05-04 10:43:48 +01:00
Wrote an edge case with the 100 recursive __index calls
This commit is contained in:
parent
22e08b7856
commit
3193501e6a
1 changed files with 2 additions and 0 deletions
|
@ -86,6 +86,8 @@ type exampleTy2 = index<typeof(exampleClass2), "Foo"> -- exampleTy2 = number
|
||||||
type exampleTy3 = index<typeof(exampleClass3), "Foo"> -- exampleTy3 = string
|
type exampleTy3 = index<typeof(exampleClass3), "Foo"> -- exampleTy3 = string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
One edge case to consider when using/designing this type operator is that `__index` only supports 100 nested `__index` metamethods until it gives up. In the case that a property is not found within the 100 recursive calls, this type operator will fail to reduce.
|
||||||
|
|
||||||
Implementation is straight forward: the type of the indexee will be determined (table, class, etc) -> search through the properties of the indexee and reduce to the corresponding type of the indexer if it exists; otherwise, reduce to an error.
|
Implementation is straight forward: the type of the indexee will be determined (table, class, etc) -> search through the properties of the indexee and reduce to the corresponding type of the indexer if it exists; otherwise, reduce to an error.
|
||||||
|
|
||||||
## Drawbacks
|
## Drawbacks
|
||||||
|
|
Loading…
Add table
Reference in a new issue