diff --git a/Analysis/src/TypeFunction.cpp b/Analysis/src/TypeFunction.cpp index 205d0fc46..9ae57fd10 100644 --- a/Analysis/src/TypeFunction.cpp +++ b/Analysis/src/TypeFunction.cpp @@ -2206,6 +2206,12 @@ TypeFunctionReductionResult indexFunctionImpl( return {std::nullopt, true, {}, {}}; TypeId indexerTy = follow(typeParams.at(1)); + + 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. diff --git a/tests/TypeFunction.test.cpp b/tests/TypeFunction.test.cpp index 1f8d7d665..2b7b40a3c 100644 --- a/tests/TypeFunction.test.cpp +++ b/tests/TypeFunction.test.cpp @@ -927,6 +927,32 @@ TEST_CASE_FIXTURE(BuiltinsFixture, "index_type_function_works") CHECK_EQ("string", toString(tpm->givenTp)); } +TEST_CASE_FIXTURE(BuiltinsFixture, "index_wait_for_pending_no_crash") +{ + if (!FFlag::LuauSolverV2) + return; + + CheckResult result = check(R"( + local PlayerData = { + Coins = 0, + Level = 1, + Exp = 0, + MaxExp = 100 + } + + type Keys = index> + + -- This function makes it think that there's going to be a pending expansion + local function UpdateData(key: Keys, value) + PlayerData[key] = value + end + + UpdateData("Coins", 2) + )"); + + // Should not crash! +} + TEST_CASE_FIXTURE(BuiltinsFixture, "index_type_function_works_w_array") { if (!FFlag::LuauSolverV2)