From 3193501e6a9ff5c522f1172b5e6e1ef81c0e1666 Mon Sep 17 00:00:00 2001 From: Junseo Yoo Date: Mon, 10 Jun 2024 15:15:03 -0700 Subject: [PATCH] Wrote an edge case with the 100 recursive __index calls --- docs/index-type-operator.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/index-type-operator.md b/docs/index-type-operator.md index 28e0cc5..d8dda56 100644 --- a/docs/index-type-operator.md +++ b/docs/index-type-operator.md @@ -86,6 +86,8 @@ type exampleTy2 = index -- exampleTy2 = number type exampleTy3 = index -- 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. ## Drawbacks