diff --git a/Analysis/include/Luau/TypeUtils.h b/Analysis/include/Luau/TypeUtils.h index 801fd4ed..8803d924 100644 --- a/Analysis/include/Luau/TypeUtils.h +++ b/Analysis/include/Luau/TypeUtils.h @@ -140,6 +140,8 @@ struct TryPair template TryPair get2(Ty one, Ty two) { + static_assert(std::is_pointer_v, "argument must be a pointer type"); + const A* a = get(one); const B* b = get(two); if (a && b) diff --git a/Analysis/src/TypeChecker2.cpp b/Analysis/src/TypeChecker2.cpp index cf404445..0badb2c5 100644 --- a/Analysis/src/TypeChecker2.cpp +++ b/Analysis/src/TypeChecker2.cpp @@ -2400,14 +2400,20 @@ struct TypeChecker2 if (reasoning.subPath.empty() && reasoning.superPath.empty()) continue; - std::optional subLeaf = traverse(subTy, reasoning.subPath, builtinTypes); - std::optional superLeaf = traverse(superTy, reasoning.superPath, builtinTypes); + std::optional optSubLeaf = traverse(subTy, reasoning.subPath, builtinTypes); + std::optional optSuperLeaf = traverse(superTy, reasoning.superPath, builtinTypes); - if (!subLeaf || !superLeaf) + if (!optSubLeaf || !optSuperLeaf) ice->ice("Subtyping test returned a reasoning with an invalid path", location); - auto [subLeafTy, superLeafTy] = get2(*subLeaf, *superLeaf); - auto [subLeafTp, superLeafTp] = get2(*subLeaf, *superLeaf); + const TypeOrPack& subLeaf = *optSubLeaf; + const TypeOrPack& superLeaf = *optSuperLeaf; + + auto subLeafTy = get(subLeaf); + auto superLeafTy = get(superLeaf); + + auto subLeafTp = get(subLeaf); + auto superLeafTp = get(superLeaf); if (!subLeafTy && !superLeafTy && !subLeafTp && !superLeafTp) ice->ice("Subtyping test returned a reasoning where one path ends at a type and the other ends at a pack.", location); @@ -2420,10 +2426,10 @@ struct TypeChecker2 std::string reason; if (reasoning.subPath == reasoning.superPath) - reason = "at " + toString(reasoning.subPath) + ", " + toString(*subLeaf) + " is not " + relation + " " + toString(*superLeaf); + reason = "at " + toString(reasoning.subPath) + ", " + toString(subLeaf) + " is not " + relation + " " + toString(superLeaf); else - reason = "type " + toString(subTy) + toString(reasoning.subPath, /* prefixDot */ true) + " (" + toString(*subLeaf) + ") is not " + - relation + " " + toString(superTy) + toString(reasoning.superPath, /* prefixDot */ true) + " (" + toString(*superLeaf) + ")"; + reason = "type " + toString(subTy) + toString(reasoning.subPath, /* prefixDot */ true) + " (" + toString(subLeaf) + ") is not " + + relation + " " + toString(superTy) + toString(reasoning.superPath, /* prefixDot */ true) + " (" + toString(superLeaf) + ")"; reasons.push_back(reason);