Skip to content

Commit 40d4815

Browse files
skberkeleyvegorov-rbxaatxeandyfriesenhgoldstein
authored
Sync to upstream/release/715 (luau-lang#2325)
The Luau team has been cooking for this week's release! 🍳 We have implemented an initial version of the [64-bit Integer Type](https://rfcs.luau.org/type-long-integer.html)! Please keep in mind that although the RFC has been accepted, we are currently in the process of identifying and fixing bugs, which may require amending the original RFC. Additionally, we've been working on the following: ### Analysis - Fix crash reported in luau-lang#2305. - Reword type-function error messages. - Fix various crashes found by fuzzer and in unit tests. - Rework how we track generalizable free types. ### Runtime - NCG: Propagate register tags across block chains. - NCG: Fix a bug in how register information was set up when entering a new block. - NCG: Fix a bug where register tag information for non-live registers was incorrectly propagated. - NCG: Remove duplicate stores of doubles and integers. - NCG: Unconditionally provide tags to read/write functions for buffers. ### Miscellaneous - Various Makefile, lldb_formatter, and lldb-dap improvements. --- Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com>
1 parent b57f54d commit 40d4815

153 files changed

Lines changed: 6301 additions & 2313 deletions

File tree

Some content is hidden

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

Analysis/include/Luau/Constraint.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,19 @@ struct Constraint
350350

351351
std::vector<NotNull<Constraint>> dependencies;
352352

353-
TypeIds getMaybeMutatedFreeTypes() const;
353+
TypeIds DEPRECATED_getMaybeMutatedFreeTypes() const;
354+
355+
/**
356+
* Return the types and type packs that may be mutated by this constraint.
357+
* Currently we do not do anything with type packs.
358+
*/
359+
std::pair<TypeIds, TypePackIds> getMaybeMutatedTypes() const;
360+
354361
};
355362

356363
using ConstraintPtr = std::unique_ptr<Constraint>;
357364

365+
bool isReferenceCountedType(TypePackId tp);
358366
bool isReferenceCountedType(const TypeId typ);
359367

360368
inline Constraint& asMutable(const Constraint& c)

Analysis/include/Luau/ConstraintGenerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ struct ConstraintGenerator
179179

180180
std::vector<TypeId> unionsToSimplify;
181181

182-
Set<TypeId> uninitializedGlobals{nullptr};
182+
Set<AstName> uninitializedGlobals{{}};
183183

184184
Polarity polarity = Polarity::None;
185185

Analysis/include/Luau/ConstraintSolver.h

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,29 @@ struct ConstraintSolver
138138
DenseHashMap<TypeId, std::vector<std::pair<Location, TypeId>>> upperBoundContributors{nullptr};
139139

140140
// A mapping from free types to the number of unresolved constraints that mention them.
141-
DenseHashMap<TypeId, size_t> unresolvedConstraints{{}};
141+
DenseHashMap<TypeId, size_t> DEPRECATED_unresolvedConstraints{{}};
142142

143-
std::unordered_map<NotNull<const Constraint>, TypeIds> maybeMutatedFreeTypes;
144-
std::unordered_map<TypeId, OrderedSet<const Constraint*>> mutatedFreeTypeToConstraint;
143+
std::unordered_map<NotNull<const Constraint>, TypeIds> DEPRECATED_maybeMutatedFreeTypes;
144+
std::unordered_map<TypeId, OrderedSet<const Constraint*>> DEPRECATED_mutatedFreeTypeToConstraint;
145+
146+
/**
147+
* A mapping from reference counted types (blocked types, free types,
148+
* unsealed table types, etc.) to the constraints that may mutate them.
149+
* When this set is empty, we can eagerly generalize the respective key.
150+
*
151+
* NOTE: Preferrably this would be a DenseHashMap rather than an
152+
* unordered_map, but DenseHashMaps require that their elements are
153+
* trivially constructable.
154+
*/
155+
std::unordered_map<TypeId, Set<const Constraint*>> typeToConstraintSet;
156+
157+
158+
/**
159+
* A mapping from constraints to the types that they mutate. We
160+
* use this set to keep track of what constraints to remove
161+
* from the values in the typeToConstraintSet.
162+
*/
163+
DenseHashMap<const Constraint*, TypeIds> constraintToMutatedTypes{nullptr};
145164

146165
// Irreducible/uninhabited type functions or type pack functions.
147166
DenseHashSet<const void*> uninhabitedTypeFunctions{{}};
@@ -400,15 +419,6 @@ struct ConstraintSolver
400419
void bind(NotNull<const Constraint> constraint, TypeId ty, TypeId boundTo);
401420
void bind(NotNull<const Constraint> constraint, TypePackId tp, TypePackId boundTo);
402421

403-
/**
404-
* Generalizes the given free type if the reference counting allows it.
405-
* @param the scope to generalize in
406-
* @param type the free type we want to generalize
407-
* @returns a non-free type that generalizes the argument, or `std::nullopt` if one
408-
* does not exist
409-
*/
410-
std::optional<TypeId> generalizeFreeType(NotNull<Scope> scope, TypeId type);
411-
412422
/**
413423
* Checks the existing set of constraints to see if there exist any that contain
414424
* the provided free type, indicating that it is not yet ready to be replaced by

Analysis/include/Luau/Error.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "Luau/Location.h"
66
#include "Luau/NotNull.h"
77
#include "Luau/Type.h"
8+
#include "Luau/TypeFunctionError.h"
89
#include "Luau/TypeIds.h"
910
#include "Luau/Variant.h"
1011

@@ -465,6 +466,13 @@ struct UserDefinedTypeFunctionError
465466
bool operator==(const UserDefinedTypeFunctionError& rhs) const;
466467
};
467468

469+
struct BuiltInTypeFunctionError
470+
{
471+
TypeFunctionError error;
472+
473+
bool operator==(const BuiltInTypeFunctionError& rhs) const;
474+
};
475+
468476
struct ReservedIdentifier
469477
{
470478
std::string name;
@@ -645,6 +653,7 @@ using TypeErrorData = Variant<
645653
UnexpectedTypePackInSubtyping,
646654
ExplicitFunctionAnnotationRecommended,
647655
UserDefinedTypeFunctionError,
656+
BuiltInTypeFunctionError,
648657
ReservedIdentifier,
649658
UnexpectedArrayLikeTableItem,
650659
CannotCheckDynamicStringFormatCalls,

Analysis/include/Luau/Instantiation2.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ struct Replacer : Substitution
5858
NotNull<DenseHashMap<TypeId, TypeId>> replacements;
5959
NotNull<DenseHashMap<TypePackId, TypePackId>> replacementPacks;
6060

61-
Replacer(NotNull<TypeArena> arena, NotNull<DenseHashMap<TypeId, TypeId>> replacements, NotNull<DenseHashMap<TypePackId, TypePackId>> replacementPacks);
61+
Replacer(
62+
NotNull<TypeArena> arena,
63+
NotNull<DenseHashMap<TypeId, TypeId>> replacements,
64+
NotNull<DenseHashMap<TypePackId, TypePackId>> replacementPacks
65+
);
6266

6367
bool isDirty(TypeId ty) override;
6468

@@ -77,7 +81,6 @@ struct Replacer : Substitution
7781
* isn't the case.
7882
*/
7983
bool checkReplacementKeys() const;
80-
8184
};
8285

8386
// A substitution which replaces generic functions by monomorphic functions

Analysis/include/Luau/Normalize.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,18 @@ namespace Luau
1818
struct InternalErrorReporter;
1919
struct Module;
2020
struct Scope;
21+
struct TypeFunctionRuntime;
2122

2223
using ModulePtr = std::shared_ptr<Module>;
2324

24-
bool isSubtype(
25+
bool isSubtype_DEPRECATED(
2526
TypeId subTy,
2627
TypeId superTy,
2728
NotNull<Scope> scope,
2829
NotNull<BuiltinTypes> builtinTypes,
2930
InternalErrorReporter& ice,
3031
SolverMode solverMode
3132
);
32-
bool isSubtype(
33-
TypePackId subPack,
34-
TypePackId superPack,
35-
NotNull<Scope> scope,
36-
NotNull<BuiltinTypes> builtinTypes,
37-
InternalErrorReporter& ice,
38-
SolverMode solverMode
39-
);
4033

4134
} // namespace Luau
4235

@@ -230,6 +223,10 @@ struct NormalizedType
230223
// This type is either never or number.
231224
TypeId numbers;
232225

226+
// The integer part of the type.
227+
// This type is either never or integer.
228+
TypeId integers;
229+
233230
// The string part of the type.
234231
// This may be the `string` type, or a union of singletons.
235232
NormalizedStringType strings;
@@ -296,6 +293,7 @@ struct NormalizedType
296293
bool hasErrors() const;
297294
bool hasNils() const;
298295
bool hasNumbers() const;
296+
bool hasIntegers() const;
299297
bool hasStrings() const;
300298
bool hasThreads() const;
301299
bool hasBuffers() const;
@@ -447,4 +445,16 @@ class Normalizer
447445
friend struct FuelInitializer;
448446
};
449447

448+
bool isSubtype(
449+
TypeId subTy,
450+
TypeId superTy,
451+
NotNull<TypeArena> arena,
452+
NotNull<BuiltinTypes> builtinTypes,
453+
NotNull<Scope> scope,
454+
NotNull<Normalizer> normalizer,
455+
NotNull<TypeFunctionRuntime> typeFunctionRuntime,
456+
NotNull<InternalErrorReporter> reporter
457+
);
458+
459+
450460
} // namespace Luau

Analysis/include/Luau/OrderedSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Luau
1111
template<typename T>
1212
struct OrderedSet
1313
{
14+
static_assert(std::is_pointer_v<T>, "OrderedSet can only be used with pointers!");
1415
using iterator = typename std::vector<T>::iterator;
1516
using const_iterator = typename std::vector<T>::const_iterator;
1617

Analysis/include/Luau/OverloadResolution.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ struct OverloadResolver
210210
// Used during overload selection to do arity-based filtering of overloads.
211211
// We do not accept nil in place of a generic unless that generic is explicitly optional.
212212
bool isArityCompatible(TypePackId candidate, TypePackId desired, NotNull<BuiltinTypes> builtinTypes) const;
213-
214213
};
215214

216215
// Helper utility, presently used for binary operator type functions.

Analysis/include/Luau/Scope.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ struct Scope
111111
DenseHashMap<std::string, Location> invalidTypeAliases{{}};
112112
std::optional<Location> isInvalidTypeAlias(const std::string& name) const;
113113

114-
// Clip with LuauReworkInfiniteTypeFinder
115-
// A set of type alias names that are invalid because they violate the recursion restrictions of type aliases.
116-
DenseHashSet<std::string> invalidTypeAliasNames_DEPRECATED{""};
117-
bool isInvalidTypeAliasName_DEPRECATED(const std::string& name) const;
118-
119114
NotNull<Scope> findNarrowestScopeContaining(Location);
120115
};
121116

Analysis/include/Luau/Subtyping.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ struct Subtyping
406406
// Pack subtyping
407407
SubtypingResult isCovariantWith(SubtypingEnvironment& env, TypePackId subTp, TypePackId superTp, NotNull<Scope> scope);
408408

409-
enum class EarlyExit {
409+
enum class EarlyExit
410+
{
410411
Yes,
411412
No
412413
};

0 commit comments

Comments
 (0)