mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-16 06:45:44 +08:00
Fix the stack-use-after-scope.
This commit is contained in:
parent
88d2b93351
commit
5559c7fbd5
@ -140,6 +140,8 @@ struct TryPair
|
||||
template<typename A, typename B, typename Ty>
|
||||
TryPair<const A*, const B*> get2(Ty one, Ty two)
|
||||
{
|
||||
static_assert(std::is_pointer_v<Ty>, "argument must be a pointer type");
|
||||
|
||||
const A* a = get<A>(one);
|
||||
const B* b = get<B>(two);
|
||||
if (a && b)
|
||||
|
@ -2400,14 +2400,20 @@ struct TypeChecker2
|
||||
if (reasoning.subPath.empty() && reasoning.superPath.empty())
|
||||
continue;
|
||||
|
||||
std::optional<TypeOrPack> subLeaf = traverse(subTy, reasoning.subPath, builtinTypes);
|
||||
std::optional<TypeOrPack> superLeaf = traverse(superTy, reasoning.superPath, builtinTypes);
|
||||
std::optional<TypeOrPack> optSubLeaf = traverse(subTy, reasoning.subPath, builtinTypes);
|
||||
std::optional<TypeOrPack> 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<TypeId, TypeId>(*subLeaf, *superLeaf);
|
||||
auto [subLeafTp, superLeafTp] = get2<TypePackId, TypePackId>(*subLeaf, *superLeaf);
|
||||
const TypeOrPack& subLeaf = *optSubLeaf;
|
||||
const TypeOrPack& superLeaf = *optSuperLeaf;
|
||||
|
||||
auto subLeafTy = get<TypeId>(subLeaf);
|
||||
auto superLeafTy = get<TypeId>(superLeaf);
|
||||
|
||||
auto subLeafTp = get<TypePackId>(subLeaf);
|
||||
auto superLeafTp = get<TypePackId>(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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user