Skip to content

Commit 1f6ff5d

Browse files
aatxehgoldsteinvrn-snayoungbloodrbxmenarulalam
authored
Sync to upstream/release/695 (#2043)
Hey there friends, apologies for the late release this week! Most of the changes amount to essentially spring (really, autumn) cleaning as we prepare for the next stage of release for the New Type Solver! We've cleaned up lots of flags, enabled regression tests that had been disabled because the New Type Solver did not support them, done some refactoring and otherwise cleaned up bits of code. None of these are really worth capturing beyond the high-level of saying we cleaned things up, but there's also a few small runtime fixes that we'll describe below. ### Runtime - Fix a bug with the argument ordering for the `vblendvps` and `vblendvpd` instructions in our Native Code Generation IR that led to `vector.lerp` having the wrong argument order in some situations when using NCG. `vector.lerp` should now behave correctly under NCG. - Remove an incorrect debug assertion in Native Code Generation's register allocation implementation for A64 assembly (i.e. for ARM's 64-bit architecture). --- Co-authored-by: Andy Friesen <[email protected]> Co-authored-by: Annie Tang <[email protected]> Co-authored-by: Ariel Weiss <[email protected]> Co-authored-by: Hunter Goldstein <[email protected]> Co-authored-by: Ilya Rezvov <[email protected]> Co-authored-by: Sora Kanosue <[email protected]> Co-authored-by: Vyacheslav Egorov <[email protected]> --------- Co-authored-by: Hunter Goldstein <[email protected]> Co-authored-by: Varun Saini <[email protected]> Co-authored-by: Alexander Youngblood <[email protected]> Co-authored-by: Menarul Alam <[email protected]> Co-authored-by: Aviral Goel <[email protected]> Co-authored-by: Vighnesh <[email protected]> Co-authored-by: Vyacheslav Egorov <[email protected]> Co-authored-by: Andy Friesen <[email protected]>
1 parent bb39565 commit 1f6ff5d

File tree

67 files changed

+1261
-1632
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1261
-1632
lines changed

Analysis/include/Luau/Subtyping.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ struct SubtypingEnvironment
178178
GenericBounds& getMappedTypeBounds(TypeId ty, NotNull<InternalErrorReporter> iceReporter);
179179
// TODO: Clip with LuauSubtypingGenericsDoesntUseVariance
180180
GenericBounds_DEPRECATED& getMappedTypeBounds_DEPRECATED(TypeId ty);
181-
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance
181+
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance2
182182
TypePackId* getMappedPackBounds_DEPRECATED(TypePackId tp);
183+
MappedGenericEnvironment::LookupResult lookupGenericPack(TypePackId tp) const;
183184

184185
/*
185186
* When we encounter a generic over the course of a subtyping test, we need
@@ -192,7 +193,7 @@ struct SubtypingEnvironment
192193
DenseHashMap<TypeId, GenericBounds_DEPRECATED> mappedGenerics_DEPRECATED{nullptr};
193194

194195
MappedGenericEnvironment mappedGenericPacks;
195-
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance
196+
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance2
196197
DenseHashMap<TypePackId, TypePackId> mappedGenericPacks_DEPRECATED{nullptr};
197198

198199
/*
@@ -452,8 +453,19 @@ struct Subtyping
452453
NotNull<Scope> scope
453454
);
454455

456+
// Markers to help overload selection.
457+
struct Anything{};
458+
struct Nothing{};
459+
460+
SubtypingResult isTailCovariantWithTail(SubtypingEnvironment& env, NotNull<Scope> scope, TypePackId subTp, const VariadicTypePack* sub, TypePackId superTp, const VariadicTypePack* super);
461+
SubtypingResult isTailCovariantWithTail(SubtypingEnvironment& env, NotNull<Scope> scope, TypePackId subTp, const GenericTypePack* sub, TypePackId superTp, const GenericTypePack* super);
462+
SubtypingResult isTailCovariantWithTail(SubtypingEnvironment& env, NotNull<Scope> scope, TypePackId subTp, const VariadicTypePack* sub, TypePackId superTp, const GenericTypePack* super);
463+
SubtypingResult isTailCovariantWithTail(SubtypingEnvironment& env, NotNull<Scope> scope, TypePackId subTp, const GenericTypePack* sub, TypePackId superTp, const VariadicTypePack* super);
464+
SubtypingResult isTailCovariantWithTail(SubtypingEnvironment& env, NotNull<Scope> scope, TypePackId subTp, const GenericTypePack* sub, Nothing);
465+
SubtypingResult isTailCovariantWithTail(SubtypingEnvironment& env, NotNull<Scope> scope, Nothing, TypePackId superTp, const GenericTypePack* super);
466+
455467
bool bindGeneric(SubtypingEnvironment& env, TypeId subTp, TypeId superTp);
456-
// Clip with LuauSubtypingGenericPacksDoesntUseVariance
468+
// Clip with LuauSubtypingGenericPacksDoesntUseVariance2
457469
bool bindGeneric_DEPRECATED(SubtypingEnvironment& env, TypePackId subTp, TypePackId superTp) const;
458470

459471
template<typename T, typename Container>

Analysis/include/Luau/TypePack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool isEmpty(TypePackId tp);
231231
/// Flattens out a type pack. Also returns a valid TypePackId tail if the type pack's full size is not known
232232
std::pair<std::vector<TypeId>, std::optional<TypePackId>> flatten(TypePackId tp);
233233
std::pair<std::vector<TypeId>, std::optional<TypePackId>> flatten(TypePackId tp, const TxnLog& log);
234-
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance
234+
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance2
235235
std::pair<std::vector<TypeId>, std::optional<TypePackId>> flatten_DEPRECATED(
236236
TypePackId tp,
237237
const DenseHashMap<TypePackId, TypePackId>& mappedGenericPacks

Analysis/include/Luau/TypePath.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ std::string toStringHuman(const TypePath::Path& path);
243243

244244
// To keep my head straight when clipping:
245245
// LuauReturnMappedGenericPacksFromSubtyping3 expects mappedGenericPacks AND arena
246-
// LuauSubtypingGenericPacksDoesntUseVariance expects just arena. this is the final state
246+
// LuauSubtypingGenericPacksDoesntUseVariance2 expects just arena. this is the final state
247247

248248
// TODO: clip below two along with `LuauReturnMappedGenericPacksFromSubtyping3`
249249
std::optional<TypeOrPack> traverse_DEPRECATED(TypeId root, const Path& path, NotNull<BuiltinTypes> builtinTypes);
250250
std::optional<TypeOrPack> traverse_DEPRECATED(TypePackId root, const Path& path, NotNull<BuiltinTypes> builtinTypes);
251251
std::optional<TypeOrPack> traverse(TypePackId root, const Path& path, NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena);
252-
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance
252+
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance2
253253
std::optional<TypeOrPack> traverse_DEPRECATED(
254254
TypePackId root,
255255
const Path& path,
@@ -258,7 +258,7 @@ std::optional<TypeOrPack> traverse_DEPRECATED(
258258
NotNull<TypeArena> arena
259259
);
260260
std::optional<TypeOrPack> traverse(TypeId root, const Path& path, NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena);
261-
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance
261+
// TODO: Clip with LuauSubtypingGenericPacksDoesntUseVariance2
262262
std::optional<TypeOrPack> traverse_DEPRECATED(
263263
TypeId root,
264264
const Path& path,

Analysis/src/Autocomplete.cpp

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "AutocompleteCore.h"
1111

1212
LUAU_FASTFLAG(LuauSolverV2)
13-
LUAU_FASTFLAG(LuauSuggestHotComments)
1413

1514
namespace Luau
1615
{
@@ -41,33 +40,17 @@ AutocompleteResult autocomplete(Frontend& frontend, const ModuleName& moduleName
4140
globalScope = frontend.globalsForAutocomplete.globalScope.get();
4241

4342
TypeArena typeArena;
44-
if (FFlag::LuauSuggestHotComments)
45-
{
46-
bool isInHotComment = isWithinHotComment(*sourceModule, position);
47-
if (isWithinComment(*sourceModule, position) && !isInHotComment)
48-
return {};
49-
50-
std::vector<AstNode*> ancestry = findAncestryAtPositionForAutocomplete(*sourceModule, position);
51-
LUAU_ASSERT(!ancestry.empty());
52-
ScopePtr startScope = findScopeAtPosition(*module, position);
53-
54-
return autocomplete_(
55-
module, builtinTypes, &typeArena, ancestry, globalScope, startScope, position, frontend.fileResolver, std::move(callback), isInHotComment
56-
);
57-
}
58-
else
59-
{
60-
if (isWithinComment(*sourceModule, position))
61-
return {};
43+
bool isInHotComment = isWithinHotComment(*sourceModule, position);
44+
if (isWithinComment(*sourceModule, position) && !isInHotComment)
45+
return {};
6246

63-
std::vector<AstNode*> ancestry = findAncestryAtPositionForAutocomplete(*sourceModule, position);
64-
LUAU_ASSERT(!ancestry.empty());
65-
ScopePtr startScope = findScopeAtPosition(*module, position);
47+
std::vector<AstNode*> ancestry = findAncestryAtPositionForAutocomplete(*sourceModule, position);
48+
LUAU_ASSERT(!ancestry.empty());
49+
ScopePtr startScope = findScopeAtPosition(*module, position);
6650

67-
return autocomplete_(
68-
module, builtinTypes, &typeArena, ancestry, globalScope, startScope, position, frontend.fileResolver, std::move(callback)
69-
);
70-
}
51+
return autocomplete_(
52+
module, builtinTypes, &typeArena, ancestry, globalScope, startScope, position, frontend.fileResolver, std::move(callback), isInHotComment
53+
);
7154
}
7255

7356
} // namespace Luau

Analysis/src/AutocompleteCore.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ LUAU_FASTFLAG(LuauSolverV2)
2727
LUAU_FASTINT(LuauTypeInferIterationLimit)
2828
LUAU_FASTINT(LuauTypeInferRecursionLimit)
2929
LUAU_FASTFLAGVARIABLE(DebugLuauMagicVariableNames)
30-
LUAU_FASTFLAGVARIABLE(LuauSuggestHotComments)
3130
LUAU_FASTFLAG(LuauAutocompleteAttributes)
3231

3332
static constexpr std::array<std::string_view, 12> kStatementStartingKeywords =
@@ -1824,16 +1823,13 @@ AutocompleteResult autocomplete_(
18241823
{
18251824
LUAU_TIMETRACE_SCOPE("Luau::autocomplete_", "AutocompleteCore");
18261825

1827-
if (FFlag::LuauSuggestHotComments)
1826+
if (isInHotComment)
18281827
{
1829-
if (isInHotComment)
1830-
{
1831-
AutocompleteEntryMap result;
1828+
AutocompleteEntryMap result;
18321829

1833-
for (const std::string_view hc : kHotComments)
1834-
result.emplace(hc, AutocompleteEntry{AutocompleteEntryKind::HotComment});
1835-
return {std::move(result), ancestry, AutocompleteContext::HotComment};
1836-
}
1830+
for (const std::string_view hc : kHotComments)
1831+
result.emplace(hc, AutocompleteEntry{AutocompleteEntryKind::HotComment});
1832+
return {std::move(result), ancestry, AutocompleteContext::HotComment};
18371833
}
18381834

18391835
AstNode* node = ancestry.back();

Analysis/src/BuiltinTypeFunctions.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
LUAU_FASTFLAG(DebugLuauEqSatSimplification)
2121
LUAU_DYNAMIC_FASTINT(LuauTypeFamilyApplicationCartesianProductLimit)
2222
LUAU_DYNAMIC_FASTINTVARIABLE(LuauStepRefineRecursionLimit, 64)
23-
LUAU_FASTFLAGVARIABLE(LuauRefineOccursCheckDirectRecursion)
2423
LUAU_FASTFLAG(LuauReduceSetTypeStackPressure)
2524

2625
LUAU_FASTFLAGVARIABLE(LuauRefineNoRefineAlways)
@@ -1184,7 +1183,7 @@ struct RefineTypeScrubber : public Substitution
11841183
return true;
11851184
}
11861185
}
1187-
return FFlag::LuauRefineOccursCheckDirectRecursion ? ty == needle : false;
1186+
return ty == needle;
11881187
}
11891188

11901189
bool ignoreChildren(TypeId ty) override
@@ -1226,7 +1225,7 @@ struct RefineTypeScrubber : public Substitution
12261225
else
12271226
return ctx->arena->addType(IntersectionType{newParts.take()});
12281227
}
1229-
else if (FFlag::LuauRefineOccursCheckDirectRecursion && ty == needle)
1228+
else if (ty == needle)
12301229
return ctx->builtins->unknownType;
12311230
else
12321231
return ty;

Analysis/src/ConstraintGenerator.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ LUAU_DYNAMIC_FASTINTVARIABLE(LuauConstraintGeneratorRecursionLimit, 300)
3737
LUAU_FASTINT(LuauCheckRecursionLimit)
3838
LUAU_FASTFLAG(DebugLuauLogSolverToJson)
3939
LUAU_FASTFLAG(DebugLuauMagicTypes)
40-
LUAU_FASTFLAGVARIABLE(LuauEnableWriteOnlyProperties)
4140
LUAU_FASTINTVARIABLE(LuauPrimitiveInferenceInTableLimit, 500)
42-
LUAU_FASTFLAGVARIABLE(LuauInferActualIfElseExprType2)
43-
LUAU_FASTFLAG(LuauLimitDynamicConstraintSolving3)
4441
LUAU_FASTFLAG(LuauEmplaceNotPushBack)
4542
LUAU_FASTFLAG(LuauReduceSetTypeStackPressure)
4643
LUAU_FASTFLAG(LuauParametrizedAttributeSyntax)
@@ -2080,13 +2077,10 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatDeclareExte
20802077
}
20812078
);
20822079

2083-
if (FFlag::LuauLimitDynamicConstraintSolving3)
2084-
{
2085-
// If we don't emplace an error type here, then later we'll be
2086-
// exposing a blocked type in this file's type interface. This
2087-
// is _normally_ harmless.
2088-
emplaceType<BoundType>(asMutable(bindingIt->second.type), builtinTypes->errorType);
2089-
}
2080+
// If we don't emplace an error type here, then later we'll be
2081+
// exposing a blocked type in this file's type interface. This
2082+
// is _normally_ harmless.
2083+
emplaceType<BoundType>(asMutable(bindingIt->second.type), builtinTypes->errorType);
20902084

20912085
return ControlFlow::None;
20922086
}
@@ -3333,10 +3327,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprIfElse* ifEls
33333327
applyRefinements(elseScope, ifElse->falseExpr->location, refinementArena.negation(refinement));
33343328
TypeId elseType = check(elseScope, ifElse->falseExpr, expectedType).ty;
33353329

3336-
if (FFlag::LuauInferActualIfElseExprType2)
3337-
return Inference{makeUnion(scope, ifElse->location, thenType, elseType)};
3338-
else
3339-
return Inference{expectedType ? *expectedType : makeUnion(scope, ifElse->location, thenType, elseType)};
3330+
return Inference{makeUnion(scope, ifElse->location, thenType, elseType)};
33403331
}
33413332

33423333
Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTypeAssertion* typeAssert)
@@ -3987,7 +3978,7 @@ TypeId ConstraintGenerator::resolveReferenceType(
39873978
else
39883979
return resolveType_(scope, ref->parameters.data[0].type, inTypeArguments);
39893980
}
3990-
else if (FFlag::LuauLimitDynamicConstraintSolving3 && ref->name == "_luau_blocked_type")
3981+
else if (ref->name == "_luau_blocked_type")
39913982
{
39923983
return arena->addType(BlockedType{});
39933984
}

Analysis/src/ConstraintSolver.cpp

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "Luau/ModuleResolver.h"
1515
#include "Luau/OverloadResolution.h"
1616
#include "Luau/RecursionCounter.h"
17+
#include "Luau/ScopedSeenSet.h"
1718
#include "Luau/Simplify.h"
1819
#include "Luau/TableLiteralInference.h"
1920
#include "Luau/TimeTrace.h"
@@ -40,8 +41,6 @@ LUAU_FASTFLAGVARIABLE(DebugLuauEqSatSimplification)
4041
LUAU_FASTFLAG(LuauTrackUniqueness)
4142
LUAU_FASTFLAG(LuauLimitUnification)
4243
LUAU_FASTFLAGVARIABLE(LuauCollapseShouldNotCrash)
43-
LUAU_FASTFLAGVARIABLE(LuauContainsAnyGenericFollowBeforeChecking)
44-
LUAU_FASTFLAGVARIABLE(LuauLimitDynamicConstraintSolving3)
4544
LUAU_FASTFLAGVARIABLE(LuauDontDynamicallyCreateRedundantSubtypeConstraints)
4645
LUAU_FASTFLAGVARIABLE(LuauExtendSealedTableUpperBounds)
4746
LUAU_FASTFLAG(LuauReduceSetTypeStackPressure)
@@ -57,28 +56,6 @@ LUAU_FASTFLAGVARIABLE(LuauAvoidOverloadSelectionForFunctionType)
5756
namespace Luau
5857
{
5958

60-
struct SeenScope
61-
{
62-
Set<TypeId>& seen;
63-
TypeId ty;
64-
65-
SeenScope(Set<TypeId>& seen, TypeId ty)
66-
: seen(seen)
67-
, ty(ty)
68-
{
69-
seen.insert(ty);
70-
}
71-
72-
~SeenScope()
73-
{
74-
seen.erase(ty);
75-
}
76-
77-
// Delete copy constructor and copy assignment operator to prevent copying
78-
SeenScope(const SeenScope&) = delete;
79-
SeenScope& operator=(const SeenScope&) = delete;
80-
};
81-
8259
bool SubtypeConstraintRecord::operator==(const SubtypeConstraintRecord& other) const
8360
{
8461
return (subTy == other.subTy) && (superTy == other.superTy) && (variance == other.variance);
@@ -530,7 +507,7 @@ void ConstraintSolver::run()
530507

531508
// If we were _given_ a limit, and the current limit has hit zero, ]
532509
// then early exit from constraint solving.
533-
if (FFlag::LuauLimitDynamicConstraintSolving3 && FInt::LuauSolverConstraintLimit > 0 && solverConstraintLimit == 0)
510+
if (FInt::LuauSolverConstraintLimit > 0 && solverConstraintLimit == 0)
534511
break;
535512

536513
std::string saveMe = FFlag::DebugLuauLogSolver ? toString(*c, opts) : std::string{};
@@ -2756,10 +2733,7 @@ struct ContainsAnyGeneric final : public TypeOnceVisitor
27562733

27572734
bool visit(TypePackId ty) override
27582735
{
2759-
if (FFlag::LuauContainsAnyGenericFollowBeforeChecking)
2760-
found = found || is<GenericTypePack>(follow(ty));
2761-
else
2762-
found = found || is<GenericTypePack>(ty);
2736+
found = found || is<GenericTypePack>(follow(ty));
27632737
return !found;
27642738
}
27652739

@@ -3103,7 +3077,8 @@ TablePropLookupResult ConstraintSolver::lookupTableProp(
31033077
if (seen.contains(subjectType))
31043078
return {};
31053079

3106-
std::optional<SeenScope> ss;
3080+
std::optional<ScopedSeenSet<Set<TypeId>, TypeId>> ss; // This won't be needed once LuauScopedSeenSetInLookupTableProp is clipped.
3081+
31073082
if (FFlag::LuauScopedSeenSetInLookupTableProp)
31083083
ss.emplace(seen, subjectType);
31093084
else
@@ -3673,15 +3648,12 @@ NotNull<Constraint> ConstraintSolver::pushConstraint(NotNull<Scope> scope, const
36733648
solverConstraints.push_back(std::move(c));
36743649
unsolvedConstraints.emplace_back(borrow);
36753650

3676-
if (FFlag::LuauLimitDynamicConstraintSolving3)
3651+
if (solverConstraintLimit > 0)
36773652
{
3678-
if (solverConstraintLimit > 0)
3679-
{
3680-
--solverConstraintLimit;
3653+
--solverConstraintLimit;
36813654

3682-
if (solverConstraintLimit == 0)
3683-
reportError(CodeTooComplex{}, location);
3684-
}
3655+
if (solverConstraintLimit == 0)
3656+
reportError(CodeTooComplex{}, location);
36853657
}
36863658

36873659
return borrow;

0 commit comments

Comments
 (0)