From e831ad2ffc6e3b644e06ede79fccb1b3a67d98a5 Mon Sep 17 00:00:00 2001 From: karl-police Date: Fri, 13 Sep 2024 14:48:31 +0200 Subject: [PATCH] Make index wait for pending indexerTy --- Analysis/src/TypeFunction.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Analysis/src/TypeFunction.cpp b/Analysis/src/TypeFunction.cpp index 205d0fc46..529d9a062 100644 --- a/Analysis/src/TypeFunction.cpp +++ b/Analysis/src/TypeFunction.cpp @@ -2206,6 +2206,19 @@ TypeFunctionReductionResult indexFunctionImpl( return {std::nullopt, true, {}, {}}; TypeId indexerTy = follow(typeParams.at(1)); + + // Whether the type is still pending. + // + // TODO: A generalized sanity check function for all type functions? + // But it should be optional for customization + // for functions that specifically need type function + // This here fixes a stack overflow. + // https://github.com/luau-lang/luau/issues/1406 + if (isPending(indexerTy, ctx->solver)) + { + return {std::nullopt, false, {indexerTy}, {}}; + } + std::shared_ptr indexerNormTy = ctx->normalizer->normalize(indexerTy); // if the indexer failed to normalize, we can't reduce, but know nothing about inhabitance.