Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 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
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
10 changes: 9 additions & 1 deletion Analysis/include/Luau/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ struct UserDefinedTypeFunctionError
bool operator==(const UserDefinedTypeFunctionError& rhs) const;
};

struct ReservedIdentifier
{
std::string name;

bool operator==(const ReservedIdentifier& rhs) const;
};

using TypeErrorData = Variant<
TypeMismatch,
UnknownSymbol,
Expand Down Expand Up @@ -504,7 +511,8 @@ using TypeErrorData = Variant<
UnexpectedTypeInSubtyping,
UnexpectedTypePackInSubtyping,
ExplicitFunctionAnnotationRecommended,
UserDefinedTypeFunctionError>;
UserDefinedTypeFunctionError,
ReservedIdentifier>;

struct TypeErrorSummary
{
Expand Down
2 changes: 1 addition & 1 deletion Analysis/include/Luau/FileResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct SourceCode
None,
Module,
Script,
Local
Local_DEPRECATED
};

std::string source;
Expand Down
42 changes: 39 additions & 3 deletions Analysis/include/Luau/Generalization.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,24 @@ struct GeneralizationParams
Polarity polarity = Polarity::None;
};

template<typename TID>
struct GeneralizationResult
{
std::optional<TID> result;

// True if the provided type was replaced with a generic.
bool wasReplacedByGeneric = false;

bool resourceLimitsExceeded = false;

explicit operator bool() const
{
return bool(result);
}
};

// Replace a single free type by its bounds according to the polarity provided.
std::optional<TypeId> generalizeType(
GeneralizationResult<TypeId> generalizeType(
NotNull<TypeArena> arena,
NotNull<BuiltinTypes> builtinTypes,
NotNull<Scope> scope,
Expand All @@ -26,7 +42,7 @@ std::optional<TypeId> generalizeType(
);

// Generalize one type pack
std::optional<TypePackId> generalizeTypePack(
GeneralizationResult<TypePackId> generalizeTypePack(
NotNull<TypeArena> arena,
NotNull<BuiltinTypes> builtinTypes,
NotNull<Scope> scope,
Expand All @@ -36,11 +52,31 @@ std::optional<TypePackId> generalizeTypePack(

void sealTable(NotNull<Scope> scope, TypeId ty);

/** Attempt to generalize a type.
*
* If generalizationTarget is set, then only that type will be replaced by its
* bounds. The way this is intended to be used is that ty is some function that
* is not fully generalized, and generalizationTarget is a type within its
* signature. There should be no further constraints that could affect the
* bounds of generalizationTarget.
*
* Returns nullopt if generalization failed due to resources limits.
*/
std::optional<TypeId> generalize(
NotNull<TypeArena> arena,
NotNull<BuiltinTypes> builtinTypes,
NotNull<Scope> scope,
NotNull<DenseHashSet<TypeId>> cachedTypes,
TypeId ty,
std::optional<TypeId> generalizationTarget = {}
);

void pruneUnnecessaryGenerics(
NotNull<TypeArena> arena,
NotNull<BuiltinTypes> builtinTypes,
NotNull<Scope> scope,
NotNull<DenseHashSet<TypeId>> cachedTypes,
TypeId ty
);
}

} // namespace Luau
3 changes: 3 additions & 0 deletions Analysis/include/Luau/Simplify.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ SimplifyResult simplifyIntersection(NotNull<BuiltinTypes> builtinTypes, NotNull<

SimplifyResult simplifyUnion(NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, TypeId left, TypeId right);

SimplifyResult simplifyIntersectWithTruthy(NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, TypeId target);
SimplifyResult simplifyIntersectWithFalsy(NotNull<BuiltinTypes> builtinTypes, NotNull<TypeArena> arena, TypeId target);

enum class Relation
{
Disjoint, // No A is a B or vice versa
Expand Down
45 changes: 14 additions & 31 deletions Analysis/include/Luau/Substitution.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct TarjanNode
struct Tarjan
{
Tarjan();
virtual ~Tarjan() = default;

// Vertices (types and type packs) are indexed, using pre-order traversal.
DenseHashMap<TypeId, int> typeToIndex{nullptr};
Expand Down Expand Up @@ -121,7 +122,7 @@ struct Tarjan
void visitChildren(TypePackId tp, int index);

void visitChild(TypeId ty);
void visitChild(TypePackId ty);
void visitChild(TypePackId tp);

template<typename Ty>
void visitChild(std::optional<Ty> ty)
Expand All @@ -132,7 +133,7 @@ struct Tarjan

// Visit the root vertex.
TarjanResult visitRoot(TypeId ty);
TarjanResult visitRoot(TypePackId ty);
TarjanResult visitRoot(TypePackId tp);

// Used to reuse the object for a new operation
void clearTarjan(const TxnLog* log);
Expand All @@ -150,26 +151,12 @@ struct Tarjan
void visitSCC(int index);

// Each subclass can decide to ignore some nodes.
virtual bool ignoreChildren(TypeId ty)
{
return false;
}

virtual bool ignoreChildren(TypePackId ty)
{
return false;
}
virtual bool ignoreChildren(TypeId ty);
virtual bool ignoreChildren(TypePackId ty);

// Some subclasses might ignore children visit, but not other actions like replacing the children
virtual bool ignoreChildrenVisit(TypeId ty)
{
return ignoreChildren(ty);
}

virtual bool ignoreChildrenVisit(TypePackId ty)
{
return ignoreChildren(ty);
}
virtual bool ignoreChildrenVisit(TypeId ty);
virtual bool ignoreChildrenVisit(TypePackId ty);

// Subclasses should say which vertices are dirty,
// and what to do with dirty vertices.
Expand All @@ -184,6 +171,7 @@ struct Tarjan
struct Substitution : Tarjan
{
protected:
explicit Substitution(TypeArena* arena);
Substitution(const TxnLog* log_, TypeArena* arena);

/*
Expand Down Expand Up @@ -232,28 +220,23 @@ struct Substitution : Tarjan
virtual TypeId clean(TypeId ty) = 0;
virtual TypePackId clean(TypePackId tp) = 0;

protected:
// Helper functions to create new types (used by subclasses)
template<typename T>
TypeId addType(const T& tv)
TypeId addType(T tv)
{
return arena->addType(tv);
return arena->addType(std::move(tv));
}

template<typename T>
TypePackId addTypePack(const T& tp)
TypePackId addTypePack(T tp)
{
return arena->addTypePack(TypePackVar{tp});
return arena->addTypePack(TypePackVar{std::move(tp)});
}

private:
template<typename Ty>
std::optional<Ty> replace(std::optional<Ty> ty)
{
if (ty)
return replace(*ty);
else
return std::nullopt;
}
std::optional<Ty> replace(std::optional<Ty> ty);
};

} // namespace Luau
6 changes: 6 additions & 0 deletions Analysis/include/Luau/TypeFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ struct TypeFunction

/// The reducer function for the type function.
ReducerFunction<TypeId> reducer;

/// If true, this type function can reduce even if it is parameterized on a generic.
bool canReduceGenerics = false;
};

/// Represents a type function that may be applied to map a series of types and
Expand All @@ -167,6 +170,9 @@ struct TypePackFunction

/// The reducer function for the type pack function.
ReducerFunction<TypePackId> reducer;

/// If true, this type function can reduce even if it is parameterized on a generic.
bool canReduceGenerics = false;
};

struct FunctionGraphReductionResult
Expand Down
1 change: 1 addition & 0 deletions Analysis/include/Luau/TypeInfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ struct TypeChecker
const PredicateVec& predicates = {}
);
WithPredicate<TypeId> checkExpr(const ScopePtr& scope, const AstExprBinary& expr, std::optional<TypeId> expectedType = std::nullopt);
WithPredicate<TypeId> checkExpr_DEPRECATED(const ScopePtr& scope, const AstExprBinary& expr, std::optional<TypeId> expectedType = std::nullopt);
WithPredicate<TypeId> checkExpr(const ScopePtr& scope, const AstExprTypeAssertion& expr);
WithPredicate<TypeId> checkExpr(const ScopePtr& scope, const AstExprError& expr);
WithPredicate<TypeId> checkExpr(const ScopePtr& scope, const AstExprIfElse& expr, std::optional<TypeId> expectedType = std::nullopt);
Expand Down
5 changes: 5 additions & 0 deletions Analysis/src/AutocompleteCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LUAU_FASTFLAGVARIABLE(LuauAutocompleteRefactorsForIncrementalAutocomplete)

LUAU_FASTFLAGVARIABLE(LuauAutocompleteUsesModuleForTypeCompatibility)
LUAU_FASTFLAGVARIABLE(LuauAutocompleteUnionCopyPreviousSeen)
LUAU_FASTFLAGVARIABLE(LuauAutocompleteMissingFollows)

static const std::unordered_set<std::string> kStatementStartingKeywords =
{"while", "if", "local", "repeat", "function", "do", "for", "return", "break", "continue", "type", "export"};
Expand Down Expand Up @@ -83,6 +84,8 @@ static ParenthesesRecommendation getParenRecommendationForIntersect(const Inters
ParenthesesRecommendation rec = ParenthesesRecommendation::None;
for (Luau::TypeId partId : intersect->parts)
{
if (FFlag::LuauAutocompleteMissingFollows)
partId = follow(partId);
if (auto partFunc = Luau::get<FunctionType>(partId))
{
rec = std::max(rec, getParenRecommendationForFunc(partFunc, nodes));
Expand Down Expand Up @@ -1623,6 +1626,8 @@ static std::optional<AutocompleteEntryMap> autocompleteStringParams(
{
for (TypeId part : intersect->parts)
{
if (FFlag::LuauAutocompleteMissingFollows)
part = follow(part);
if (auto candidateFunctionType = Luau::get<FunctionType>(part))
{
if (std::optional<AutocompleteEntryMap> ret = performCallback(candidateFunctionType))
Expand Down
8 changes: 4 additions & 4 deletions Analysis/src/BuiltinDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/

LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAG(LuauNonReentrantGeneralization)
LUAU_FASTFLAG(LuauNonReentrantGeneralization2)
LUAU_FASTFLAGVARIABLE(LuauTableCloneClonesType3)
LUAU_FASTFLAG(LuauTrackInteriorFreeTypesOnScope)
LUAU_FASTFLAGVARIABLE(LuauFollowTableFreeze)
Expand Down Expand Up @@ -314,8 +314,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::LuauNonReentrantGeneralization
if (FFlag::LuauNonReentrantGeneralization)
Scope* globalScope = nullptr; // NotNull<Scope> when removing FFlag::LuauNonReentrantGeneralization2
if (FFlag::LuauNonReentrantGeneralization2)
globalScope = globals.globalScope.get();

if (FFlag::LuauSolverV2)
Expand Down Expand Up @@ -1614,7 +1614,7 @@ bool MagicFreeze::infer(const MagicFunctionCallContext& context)
if (resultTy && !get<BlockedType>(resultTy))
{
// If there's an existing result type but it's _not_ blocked, then
// we aren't type stating this builtin and should fall back to
// we aren't type stating this builtin and should fall back to
// regular inference.
return false;
}
Expand Down
Loading