Skip to content

Sync to upstream/release/674 #1832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
765591c
Sync to origin/release/656
hgoldstein Jan 10, 2025
a0ed331
Merge branch 'upstream' into merge
hgoldstein Jan 10, 2025
ba71ff1
Explicitly cast size_t to uint64_t in buffer_readbits / buffer_writebits
hgoldstein Jan 10, 2025
aaaeae5
Sync to upstream/release/657
vrn-sn Jan 17, 2025
790dc17
Merge branch 'master' into merge
vrn-sn Jan 17, 2025
c6e2b53
Merge branch 'upstream' into merge
vrn-sn Jan 17, 2025
76e0958
Include <algorithm> and <vector> in IrUtils.cpp
vrn-sn Jan 17, 2025
23241e2
Sync to upstream/release/658
ayoungbloodrbx Jan 24, 2025
6167275
Merge branch 'master' into merge
ayoungbloodrbx Jan 24, 2025
ec5643d
Merge branch 'upstream' into merge
ayoungbloodrbx Jan 24, 2025
768a3a2
Remove duplicate flag
ayoungbloodrbx Jan 24, 2025
c31654d
Move duplicate flag back
ayoungbloodrbx Jan 24, 2025
072195b
Merge branch 'master' into merge
menarulalam Feb 1, 2025
5f0bd2f
Sync to upstream/release/659
menarulalam Feb 1, 2025
a699a21
Merge branch 'upstream' into merge
menarulalam Feb 1, 2025
a3630ef
Merge branch 'upstream' into merge
menarulalam Feb 1, 2025
df60533
Sync to upstream/release/659
menarulalam Feb 1, 2025
7199da8
Sync to upstream/release/660
Feb 7, 2025
fd9b8b0
Merge branch 'master' into merge
Feb 7, 2025
198c1f7
Merge branch 'upstream' into merge
Feb 7, 2025
6b30374
Cast types appropriately to fix compilation error.
Feb 7, 2025
d17d70d
Merge branch 'upstream' into merge
Feb 7, 2025
c9a4113
Explicitly enable FFlags in interpolated string Transpiler tests
Feb 8, 2025
587cf13
Sync to upstream/release/661
Vighnesh-V Feb 14, 2025
aab18f3
Merge branch 'master' into merge
Vighnesh-V Feb 14, 2025
1d001c4
Merge branch 'upstream' into merge
Vighnesh-V Feb 14, 2025
69afd59
Correctly apply unsigned casting patch to merge branch
Vighnesh-V Feb 14, 2025
279e15a
Sync to upstream/release/662
vegorov-rbx Feb 21, 2025
1c3720a
Merge branch 'master' into merge
vegorov-rbx Feb 21, 2025
4717228
Merge branch 'upstream' into merge
vegorov-rbx Feb 21, 2025
6a8da81
Merge fix
vegorov-rbx Feb 21, 2025
b6ca2a0
Sync to upstream/release/663
aatxe Feb 28, 2025
4b3b32a
Merge branch 'master' into merge
aatxe Feb 28, 2025
f43ebc2
Merge branch 'upstream' into merge
aatxe Feb 28, 2025
7568957
Sync to upstream/release/664
vegorov-rbx Mar 7, 2025
a0fad72
Merge branch 'master' into merge
vegorov-rbx Mar 7, 2025
23bc546
Merge branch 'upstream' into merge
vegorov-rbx Mar 7, 2025
af20253
Sync to upstream/release/665
hgoldstein Mar 14, 2025
df92b6c
Merge branch 'master' into merge
hgoldstein Mar 14, 2025
de3f3d2
Merge branch 'upstream' into merge
hgoldstein Mar 14, 2025
2eefa3f
Sync to upstream/release/666
vrn-sn Mar 21, 2025
a371d16
Merge branch 'master' into merge
vrn-sn Mar 21, 2025
716f524
Merge branch 'upstream' into merge
vrn-sn Mar 21, 2025
d4c2c64
Sync to upstream/release/667
ayoungbloodrbx Mar 28, 2025
9ae5f37
Merge branch 'master' into merge
ayoungbloodrbx Mar 28, 2025
08f07a1
Merge branch 'upstream' into merge
ayoungbloodrbx Mar 28, 2025
d9e8ded
Sync to upstream/release/668
Apr 4, 2025
f85407b
Merge branch 'master' into merge
Apr 4, 2025
6e90f90
Merge branch 'upstream' into merge
Apr 4, 2025
d2969f0
Disable failing tests until fixes have been found.
Apr 4, 2025
7a6b561
Sync to upstream/release/669
menarulalam Apr 11, 2025
c3f6c48
Merge branch 'master' into merge
menarulalam Apr 11, 2025
567876e
Merge branch 'upstream' into merge
menarulalam Apr 11, 2025
afaceca
Add missing MIT License header
vrn-sn Apr 11, 2025
8f61efb
Make RequireNavigator depend on Config (hacky, will improve later)
vrn-sn Apr 12, 2025
217c14d
Sync to upstream/release/670
Vighnesh-V Apr 18, 2025
3d1ac20
Merge branch 'master' into merge
Vighnesh-V Apr 18, 2025
2f6fb98
Merge branch 'upstream' into merge
Vighnesh-V Apr 18, 2025
500f8d4
update test cases to use NonReentrantGeneralization2
Vighnesh-V Apr 18, 2025
2b7a89d
Sync to upstream/release/671
andyfriesen Apr 25, 2025
e9ef63d
Merge branch 'master' into merge
andyfriesen Apr 25, 2025
1b78172
Merge branch 'upstream' into merge
andyfriesen Apr 25, 2025
18b36c1
Delete .clang-tidy
andyfriesen Apr 25, 2025
3adf258
Sync to upstream/release/672
aatxe May 2, 2025
7d27130
Merge branch 'master' into merge
aatxe May 2, 2025
27a8fd0
Merge branch 'upstream' into merge
aatxe May 2, 2025
335ec70
Sync to upstream/release/673
andyfriesen May 9, 2025
0e65d3f
Merge branch 'master' into merge
andyfriesen May 9, 2025
209ae16
Merge branch 'upstream' into merge
andyfriesen May 9, 2025
7975c23
Sync to upstream/release/674
hgoldstein May 16, 2025
514848a
Merge branch 'master' into merge
hgoldstein May 16, 2025
bd532d1
Merge branch 'upstream' into merge
hgoldstein May 16, 2025
aecc30f
Disable non-reentrant generalization in 'fuzz_propagate_normalization…
hgoldstein May 16, 2025
74fac86
Just disable 'fuzz_propagate_normalization_failures' for now
hgoldstein May 16, 2025
2d961d6
Also disable 'fuzz_limit_function_intersection_complexity', for now
hgoldstein May 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Analysis/include/Luau/BuiltinDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Luau
{

static constexpr char kRequireTagName[] = "require";
inline constexpr char kRequireTagName[] = "require";

struct Frontend;
struct GlobalTypes;
Expand Down
9 changes: 8 additions & 1 deletion Analysis/include/Luau/Constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ struct ReducePackConstraint
TypePackId tp;
};

// simplify ty
struct SimplifyConstraint
{
TypeId ty;
};

using ConstraintV = Variant<
SubtypeConstraint,
PackSubtypeConstraint,
Expand All @@ -294,7 +300,8 @@ using ConstraintV = Variant<
ReduceConstraint,
ReducePackConstraint,
EqualityConstraint,
TableCheckConstraint>;
TableCheckConstraint,
SimplifyConstraint>;

struct Constraint
{
Expand Down
8 changes: 8 additions & 0 deletions Analysis/include/Luau/ConstraintGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ struct ConstraintGenerator
std::vector<std::vector<TypeId>> DEPRECATED_interiorTypes;
std::vector<InteriorFreeTypes> interiorFreeTypes;

std::vector<TypeId> unionsToSimplify;

/**
* Fabricates a new free type belonging to a given scope.
* @param scope the scope the free type belongs to.
Expand Down Expand Up @@ -447,6 +449,12 @@ struct ConstraintGenerator

// make a union type function of these two types
TypeId makeUnion(const ScopePtr& scope, Location location, TypeId lhs, TypeId rhs);

// Make a union type and add it to `unionsToSimplify`, ensuring that
// later we will attempt to simplify this union in order to keep types
// small.
TypeId makeUnion(std::vector<TypeId> options);

// make an intersect type function of these two types
TypeId makeIntersect(const ScopePtr& scope, Location location, TypeId lhs, TypeId rhs);
void prepopulateGlobalScopeForFragmentTypecheck(const ScopePtr& globalScope, const ScopePtr& resumeScope, AstStatBlock* program);
Expand Down
2 changes: 2 additions & 0 deletions Analysis/include/Luau/ConstraintSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ struct ConstraintSolver
bool tryDispatch(const ReducePackConstraint& c, NotNull<const Constraint> constraint, bool force);
bool tryDispatch(const EqualityConstraint& c, NotNull<const Constraint> constraint);

bool tryDispatch(const SimplifyConstraint& c, NotNull<const Constraint> constraint);

// for a, ... in some_table do
// also handles __iter metamethod
bool tryDispatchIterableTable(TypeId iteratorTy, const IterableConstraint& c, NotNull<const Constraint> constraint, bool force);
Expand Down
8 changes: 7 additions & 1 deletion Analysis/include/Luau/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ struct ReservedIdentifier
bool operator==(const ReservedIdentifier& rhs) const;
};

struct UnexpectedArrayLikeTableItem
{
bool operator==(const UnexpectedArrayLikeTableItem&) const { return true; }
};

using TypeErrorData = Variant<
TypeMismatch,
UnknownSymbol,
Expand Down Expand Up @@ -512,7 +517,8 @@ using TypeErrorData = Variant<
UnexpectedTypePackInSubtyping,
ExplicitFunctionAnnotationRecommended,
UserDefinedTypeFunctionError,
ReservedIdentifier>;
ReservedIdentifier,
UnexpectedArrayLikeTableItem>;

struct TypeErrorSummary
{
Expand Down
4 changes: 2 additions & 2 deletions Analysis/include/Luau/Metamethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Luau
{

static const std::unordered_map<AstExprBinary::Op, const char*> kBinaryOpMetamethods{
inline const std::unordered_map<AstExprBinary::Op, const char*> kBinaryOpMetamethods{
{AstExprBinary::Op::CompareEq, "__eq"},
{AstExprBinary::Op::CompareNe, "__eq"},
{AstExprBinary::Op::CompareGe, "__lt"},
Expand All @@ -25,7 +25,7 @@ static const std::unordered_map<AstExprBinary::Op, const char*> kBinaryOpMetamet
{AstExprBinary::Op::Concat, "__concat"},
};

static const std::unordered_map<AstExprUnary::Op, const char*> kUnaryOpMetamethods{
inline const std::unordered_map<AstExprUnary::Op, const char*> kUnaryOpMetamethods{
{AstExprUnary::Op::Minus, "__unm"},
{AstExprUnary::Op::Len, "__len"},
};
Expand Down
2 changes: 1 addition & 1 deletion Analysis/include/Luau/Subtyping.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct SubtypingReasoningHash
};

using SubtypingReasonings = DenseHashSet<SubtypingReasoning, SubtypingReasoningHash>;
static const SubtypingReasoning kEmptyReasoning = SubtypingReasoning{TypePath::kEmpty, TypePath::kEmpty, SubtypingVariance::Invalid};
inline const SubtypingReasoning kEmptyReasoning = SubtypingReasoning{TypePath::kEmpty, TypePath::kEmpty, SubtypingVariance::Invalid};

struct SubtypingResult
{
Expand Down
2 changes: 1 addition & 1 deletion Analysis/include/Luau/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ std::vector<TypeId> filterMap(TypeId type, TypeIdPredicate predicate);

// A tag to mark a type which doesn't derive directly from the root type as overriding the return of `typeof`.
// Any classes which derive from this type will have typeof return this type.
static constexpr char kTypeofRootTag[] = "typeofRoot";
inline constexpr char kTypeofRootTag[] = "typeofRoot";

void attachTag(TypeId ty, const std::string& tagName);
void attachTag(Property& prop, const std::string& tagName);
Expand Down
3 changes: 3 additions & 0 deletions Analysis/include/Luau/TypeChecker2.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ struct TypeChecker2

void explainError(TypeId subTy, TypeId superTy, Location location, const SubtypingResult& result);
void explainError(TypePackId subTy, TypePackId superTy, Location location, const SubtypingResult& result);

bool testPotentialLiteralIsSubtype(AstExpr* expr, TypeId expectedTy);

bool testIsSubtype(TypeId subTy, TypeId superTy, Location location);
bool testIsSubtype(TypePackId subTy, TypePackId superTy, Location location);
void reportError(TypeError e);
Expand Down
3 changes: 0 additions & 3 deletions Analysis/include/Luau/TypeFunctionRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ struct TypeFunctionExternType

std::optional<TypeFunctionTypeId> metatable; // metaclass?

// this was mistaken, and we should actually be keeping separate read/write types here.
std::optional<TypeFunctionTypeId> parent_DEPRECATED;

std::optional<TypeFunctionTypeId> readParent;
std::optional<TypeFunctionTypeId> writeParent;

Expand Down
2 changes: 1 addition & 1 deletion Analysis/include/Luau/TypePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct PathHash
};

/// The canonical "empty" Path, meaning a Path with no components.
static const Path kEmpty{};
inline const Path kEmpty{};

struct PathBuilder
{
Expand Down
10 changes: 10 additions & 0 deletions Analysis/include/Luau/TypeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,14 @@ void trackInteriorFreeType(Scope* scope, TypeId ty);

void trackInteriorFreeTypePack(Scope* scope, TypePackId tp);

// A fast approximation of subTy <: superTy
bool fastIsSubtype(TypeId subTy, TypeId superTy);

/**
* @param tables A list of potential table parts of a union
* @param exprType Type of the expression to match
* @return An element of `tables` that best matches `exprType`.
*/
std::optional<TypeId> extractMatchingTableType(std::vector<TypeId>& tables, TypeId exprType, NotNull<BuiltinTypes> builtinTypes);

} // namespace Luau
10 changes: 3 additions & 7 deletions Analysis/src/AutocompleteCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ LUAU_FASTINT(LuauTypeInferIterationLimit)
LUAU_FASTINT(LuauTypeInferRecursionLimit)
LUAU_FASTFLAGVARIABLE(DebugLuauMagicVariableNames)
LUAU_FASTFLAGVARIABLE(LuauAutocompleteUsesModuleForTypeCompatibility)
LUAU_FASTFLAGVARIABLE(LuauAutocompleteUnionCopyPreviousSeen)
LUAU_FASTFLAGVARIABLE(LuauAutocompleteMissingFollows)
LUAU_FASTFLAG(LuauStoreReturnTypesAsPackOnAst)

Expand Down Expand Up @@ -490,13 +489,10 @@ static void autocompleteProps(
// t1 where t1 = t1 | ExternType
//
// Then we are on a one way journey to a stack overflow.
if (FFlag::LuauAutocompleteUnionCopyPreviousSeen)
for (auto ty : seen)
{
for (auto ty : seen)
{
if (is<UnionType, IntersectionType>(ty))
innerSeen.insert(ty);
}
if (is<UnionType, IntersectionType>(ty))
innerSeen.insert(ty);
}

if (isNil(*iter))
Expand Down
120 changes: 49 additions & 71 deletions Analysis/src/BuiltinDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
*/

LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAG(LuauNonReentrantGeneralization2)
LUAU_FASTFLAG(LuauNonReentrantGeneralization3)
LUAU_FASTFLAGVARIABLE(LuauTableCloneClonesType3)
LUAU_FASTFLAGVARIABLE(LuauUserTypeFunTypecheck)
LUAU_FASTFLAGVARIABLE(LuauMagicFreezeCheckBlocked2)
LUAU_FASTFLAGVARIABLE(LuauFormatUseLastPosition)

Expand Down Expand Up @@ -292,8 +291,6 @@ void assignPropDocumentationSymbols(TableType::Props& props, const std::string&

static void finalizeGlobalBindings(ScopePtr scope)
{
LUAU_ASSERT(FFlag::LuauUserTypeFunTypecheck);

for (const auto& pair : scope->bindings)
{
persist(pair.second.typeId);
Expand All @@ -313,8 +310,8 @@ void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeC

TypeArena& arena = globals.globalTypes;
NotNull<BuiltinTypes> builtinTypes = globals.builtinTypes;
Scope* globalScope = nullptr; // NotNull<Scope> when removing FFlag::LuauNonReentrantGeneralization2
if (FFlag::LuauNonReentrantGeneralization2)
Scope* globalScope = nullptr; // NotNull<Scope> when removing FFlag::LuauNonReentrantGeneralization3
if (FFlag::LuauNonReentrantGeneralization3)
globalScope = globals.globalScope.get();

if (FFlag::LuauSolverV2)
Expand Down Expand Up @@ -420,23 +417,7 @@ void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeC
// clang-format on
}

if (FFlag::LuauUserTypeFunTypecheck)
{
finalizeGlobalBindings(globals.globalScope);
}
else
{
for (const auto& pair : globals.globalScope->bindings)
{
persist(pair.second.typeId);

if (TableType* ttv = getMutable<TableType>(pair.second.typeId))
{
if (!ttv->name)
ttv->name = "typeof(" + toString(pair.first) + ")";
}
}
}
finalizeGlobalBindings(globals.globalScope);

attachMagicFunction(getGlobalBinding(globals, "assert"), std::make_shared<MagicAssert>());

Expand Down Expand Up @@ -500,58 +481,55 @@ void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeC
attachTag(requireTy, kRequireTagName);
attachMagicFunction(requireTy, std::make_shared<MagicRequire>());

if (FFlag::LuauUserTypeFunTypecheck)
{
// Global scope cannot be the parent of the type checking environment because it can be changed by the embedder
globals.globalTypeFunctionScope->exportedTypeBindings = globals.globalScope->exportedTypeBindings;
globals.globalTypeFunctionScope->builtinTypeNames = globals.globalScope->builtinTypeNames;

// Type function runtime also removes a few standard libraries and globals, so we will take only the ones that are defined
static const char* typeFunctionRuntimeBindings[] = {
// Libraries
"math",
"table",
"string",
"bit32",
"utf8",
"buffer",

// Globals
"assert",
"error",
"print",
"next",
"ipairs",
"pairs",
"select",
"unpack",
"getmetatable",
"setmetatable",
"rawget",
"rawset",
"rawlen",
"rawequal",
"tonumber",
"tostring",
"type",
"typeof",
};
// Global scope cannot be the parent of the type checking environment because it can be changed by the embedder
globals.globalTypeFunctionScope->exportedTypeBindings = globals.globalScope->exportedTypeBindings;
globals.globalTypeFunctionScope->builtinTypeNames = globals.globalScope->builtinTypeNames;

// Type function runtime also removes a few standard libraries and globals, so we will take only the ones that are defined
static const char* typeFunctionRuntimeBindings[] = {
// Libraries
"math",
"table",
"string",
"bit32",
"utf8",
"buffer",

// Globals
"assert",
"error",
"print",
"next",
"ipairs",
"pairs",
"select",
"unpack",
"getmetatable",
"setmetatable",
"rawget",
"rawset",
"rawlen",
"rawequal",
"tonumber",
"tostring",
"type",
"typeof",
};

for (auto& name : typeFunctionRuntimeBindings)
{
AstName astName = globals.globalNames.names->get(name);
LUAU_ASSERT(astName.value);
for (auto& name : typeFunctionRuntimeBindings)
{
AstName astName = globals.globalNames.names->get(name);
LUAU_ASSERT(astName.value);

globals.globalTypeFunctionScope->bindings[astName] = globals.globalScope->bindings[astName];
}
globals.globalTypeFunctionScope->bindings[astName] = globals.globalScope->bindings[astName];
}

LoadDefinitionFileResult typeFunctionLoadResult = frontend.loadDefinitionFile(
globals, globals.globalTypeFunctionScope, getTypeFunctionDefinitionSource(), "@luau", /* captureComments */ false, false
);
LUAU_ASSERT(typeFunctionLoadResult.success);
LoadDefinitionFileResult typeFunctionLoadResult = frontend.loadDefinitionFile(
globals, globals.globalTypeFunctionScope, getTypeFunctionDefinitionSource(), "@luau", /* captureComments */ false, false
);
LUAU_ASSERT(typeFunctionLoadResult.success);

finalizeGlobalBindings(globals.globalTypeFunctionScope);
}
finalizeGlobalBindings(globals.globalTypeFunctionScope);
}

static std::vector<TypeId> parseFormatString(NotNull<BuiltinTypes> builtinTypes, const char* data, size_t size)
Expand Down
4 changes: 0 additions & 4 deletions Analysis/src/Constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ DenseHashSet<TypeId> Constraint::getMaybeMutatedFreeTypes() const
rci.traverse(ty);
// `UnpackConstraint` should not mutate `sourcePack`.
}
else if (auto rpc = get<ReduceConstraint>(*this); FFlag::DebugLuauGreedyGeneralization && rpc)
{
rci.traverse(rpc->ty);
}
else if (auto rpc = get<ReducePackConstraint>(*this))
{
rci.traverse(rpc->tp);
Expand Down
Loading