Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 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
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
4 changes: 2 additions & 2 deletions Analysis/include/Luau/AutocompleteTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct AutocompleteEntry
// Set if this suggestion matches the type expected in the context
TypeCorrectKind typeCorrect = TypeCorrectKind::None;

std::optional<const ClassType*> containingClass = std::nullopt;
std::optional<const ExternType*> containingExternType = std::nullopt;
std::optional<const Property*> prop = std::nullopt;
std::optional<std::string> documentationSymbol = std::nullopt;
Tags tags;
Expand Down Expand Up @@ -85,7 +85,7 @@ struct AutocompleteResult
};

using StringCompletionCallback =
std::function<std::optional<AutocompleteEntryMap>(std::string tag, std::optional<const ClassType*> ctx, std::optional<std::string> contents)>;
std::function<std::optional<AutocompleteEntryMap>(std::string tag, std::optional<const ExternType*> ctx, std::optional<std::string> contents)>;

constexpr char kGeneratedAnonymousFunctionEntryName[] = "function (anonymous autofilled)";

Expand Down
16 changes: 7 additions & 9 deletions Analysis/include/Luau/ConstraintGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Luau/Ast.h"
#include "Luau/Constraint.h"
#include "Luau/ConstraintSet.h"
#include "Luau/ControlFlow.h"
#include "Luau/DataFlowGraph.h"
#include "Luau/EqSatSimplification.h"
Expand Down Expand Up @@ -91,9 +92,8 @@ struct ConstraintGenerator
// Constraints that go straight to the solver.
std::vector<ConstraintPtr> constraints;

// Constraints that do not go to the solver right away. Other constraints
// will enqueue them during solving.
std::vector<ConstraintPtr> unqueuedConstraints;
// The set of all free types introduced during constraint generation.
DenseHashSet<TypeId> freeTypes{nullptr};

// Map a function's signature scope back to its signature type.
DenseHashMap<Scope*, TypeId> scopeToFunction{nullptr};
Expand Down Expand Up @@ -151,6 +151,9 @@ struct ConstraintGenerator
std::vector<RequireCycle> requireCycles
);

ConstraintSet run(AstStatBlock* block);
ConstraintSet runOnFragment(const ScopePtr& resumeScope, AstStatBlock* block);

/**
* The entry point to the ConstraintGenerator. This will construct a set
* of scopes, constraints, and free types that can be solved later.
Expand Down Expand Up @@ -269,7 +272,7 @@ struct ConstraintGenerator
ControlFlow visit(const ScopePtr& scope, AstStatTypeAlias* alias);
ControlFlow visit(const ScopePtr& scope, AstStatTypeFunction* function);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareGlobal* declareGlobal);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareClass* declareClass);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareExternType* declareExternType);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareFunction* declareFunction);
ControlFlow visit(const ScopePtr& scope, AstStatError* error);

Expand Down Expand Up @@ -481,9 +484,4 @@ struct ConstraintGenerator
TypeId simplifyUnion(const ScopePtr& scope, Location location, TypeId left, TypeId right);
};

/** Borrow a vector of pointers from a vector of owning pointers to constraints.
*/
std::vector<NotNull<Constraint>> borrowConstraints(const std::vector<ConstraintPtr>& constraints);


} // namespace Luau
32 changes: 32 additions & 0 deletions Analysis/include/Luau/ConstraintSet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details

#pragma once

#include "Luau/Constraint.h"
#include "Luau/DenseHash.h"
#include "Luau/Error.h"

#include <vector>

namespace Luau
{

struct ConstraintSet
{
NotNull<Scope> rootScope;

std::vector<ConstraintPtr> constraints;

// The set of all free types created during constraint generation
DenseHashSet<TypeId> freeTypes{nullptr};

// Map a function's signature scope back to its signature type. Once we've
// dispatched all of the constraints pertaining to a particular free type,
// we use this mapping to generalize that free type.
DenseHashMap<Scope*, TypeId> scopeToFunction{nullptr};

// It is pretty uncommon for constraint generation to itself produce errors, but it can happen.
std::vector<TypeError> errors;
};

}
22 changes: 22 additions & 0 deletions Analysis/include/Luau/ConstraintSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include "Luau/Constraint.h"
#include "Luau/ConstraintSet.h"
#include "Luau/DataFlowGraph.h"
#include "Luau/DenseHash.h"
#include "Luau/EqSatSimplification.h"
Expand Down Expand Up @@ -87,6 +88,7 @@ struct ConstraintSolver
NotNull<Simplifier> simplifier;
NotNull<TypeFunctionRuntime> typeFunctionRuntime;
// The entire set of constraints that the solver is trying to resolve.
ConstraintSet constraintSet;
std::vector<NotNull<Constraint>> constraints;
NotNull<DenseHashMap<Scope*, TypeId>> scopeToFunction;
NotNull<Scope> rootScope;
Expand Down Expand Up @@ -140,6 +142,19 @@ struct ConstraintSolver

DenseHashMap<TypeId, const Constraint*> typeFunctionsToFinalize{nullptr};

explicit ConstraintSolver(
NotNull<Normalizer> normalizer,
NotNull<Simplifier> simplifier,
NotNull<TypeFunctionRuntime> typeFunctionRuntime,
ModuleName moduleName,
NotNull<ModuleResolver> moduleResolver,
std::vector<RequireCycle> requireCycles,
DcrLogger* logger,
NotNull<const DataFlowGraph> dfg,
TypeCheckLimits limits,
ConstraintSet constraintSet
);

explicit ConstraintSolver(
NotNull<Normalizer> normalizer,
NotNull<Simplifier> simplifier,
Expand Down Expand Up @@ -174,6 +189,9 @@ struct ConstraintSolver
bool isDone() const;

private:
/// A helper that does most of the setup work that is shared between the two constructors.
void initFreeTypeTracking();

void generalizeOneType(TypeId ty);

/**
Expand Down Expand Up @@ -432,6 +450,10 @@ struct ConstraintSolver
void fillInDiscriminantTypes(NotNull<const Constraint> constraint, const std::vector<std::optional<TypeId>>& discriminantTypes);
};

/** Borrow a vector of pointers from a vector of owning pointers to constraints.
*/
std::vector<NotNull<Constraint>> borrowConstraints(const std::vector<ConstraintPtr>& constraints);

void dump(NotNull<Scope> rootScope, struct ToStringOptions& opts);

} // namespace Luau
2 changes: 1 addition & 1 deletion Analysis/include/Luau/DataFlowGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ struct DataFlowGraphBuilder
ControlFlow visit(AstStatTypeFunction* f);
ControlFlow visit(AstStatDeclareGlobal* d);
ControlFlow visit(AstStatDeclareFunction* d);
ControlFlow visit(AstStatDeclareClass* d);
ControlFlow visit(AstStatDeclareExternType* d);
ControlFlow visit(AstStatError* error);

DataFlowResult visitExpr(AstExpr* e);
Expand Down
6 changes: 3 additions & 3 deletions Analysis/include/Luau/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ struct TypePackMismatch
bool operator==(const TypePackMismatch& rhs) const;
};

struct DynamicPropertyLookupOnClassesUnsafe
struct DynamicPropertyLookupOnExternTypesUnsafe
{
TypeId ty;

bool operator==(const DynamicPropertyLookupOnClassesUnsafe& rhs) const;
bool operator==(const DynamicPropertyLookupOnExternTypesUnsafe& rhs) const;
};

struct UninhabitedTypeFunction
Expand Down Expand Up @@ -499,7 +499,7 @@ using TypeErrorData = Variant<
TypesAreUnrelated,
NormalizationTooComplex,
TypePackMismatch,
DynamicPropertyLookupOnClassesUnsafe,
DynamicPropertyLookupOnExternTypesUnsafe,
UninhabitedTypeFunction,
UninhabitedTypePackFunction,
WhereClauseNeeded,
Expand Down
3 changes: 1 addition & 2 deletions Analysis/include/Luau/FileResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ struct FileResolver
return std::nullopt;
}

// Make non-virtual when removing FFlagLuauImproveRequireByStringAutocomplete.
virtual std::optional<RequireSuggestions> getRequireSuggestions(const ModuleName& requirer, const std::optional<std::string>& pathString) const;
std::optional<RequireSuggestions> getRequireSuggestions(const ModuleName& requirer, const std::optional<std::string>& pathString) const;

std::shared_ptr<RequireSuggester> requireSuggester;
};
Expand Down
4 changes: 2 additions & 2 deletions Analysis/include/Luau/Instantiation.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ struct GenericTypeFinder : TypeOnceVisitor
return false;
}

bool visit(TypeId ty, const Luau::ClassType&) override
bool visit(TypeId ty, const Luau::ExternType&) override
{
// During function instantiation, classes are not traversed even if they have generics
// During function instantiation, extern types are not traversed even if they have generics
return false;
}
};
Expand Down
22 changes: 11 additions & 11 deletions Analysis/include/Luau/Normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ struct NormalizedStringType

bool isSubtype(const NormalizedStringType& subStr, const NormalizedStringType& superStr);

struct NormalizedClassType
struct NormalizedExternType
{
/** Has the following structure:
*
Expand All @@ -192,7 +192,7 @@ struct NormalizedClassType
*
* Each TypeId is a class type.
*/
std::unordered_map<TypeId, TypeIds> classes;
std::unordered_map<TypeId, TypeIds> externTypes;

/**
* In order to maintain a consistent insertion order, we use this vector to
Expand Down Expand Up @@ -245,7 +245,7 @@ enum class NormalizationResult
};

// A normalized type is either any, unknown, or one of the form P | T | F | G where
// * P is a union of primitive types (including singletons, classes and the error type)
// * P is a union of primitive types (including singletons, extern types and the error type)
// * T is a union of table types
// * F is a union of an intersection of function types
// * G is a union of generic/free/blocked types, intersected with a normalized type
Expand All @@ -260,7 +260,7 @@ struct NormalizedType
// This type is either never, boolean type, or a boolean singleton.
TypeId booleans;

NormalizedClassType classes;
NormalizedExternType externTypes;

// The error part of the type.
// This type is either never or the error type.
Expand Down Expand Up @@ -333,7 +333,7 @@ struct NormalizedType
// Helpers that improve readability of the above (they just say if the component is present)
bool hasTops() const;
bool hasBooleans() const;
bool hasClasses() const;
bool hasExternTypes() const;
bool hasErrors() const;
bool hasNils() const;
bool hasNumbers() const;
Expand Down Expand Up @@ -391,10 +391,10 @@ class Normalizer
void unionTysWithTy(TypeIds& here, TypeId there);
TypeId unionOfTops(TypeId here, TypeId there);
TypeId unionOfBools(TypeId here, TypeId there);
void unionClassesWithClass(TypeIds& heres, TypeId there);
void unionClasses(TypeIds& heres, const TypeIds& theres);
void unionClassesWithClass(NormalizedClassType& heres, TypeId there);
void unionClasses(NormalizedClassType& heres, const NormalizedClassType& theres);
void unionExternTypesWithExternType(TypeIds& heres, TypeId there);
void unionExternTypes(TypeIds& heres, const TypeIds& theres);
void unionExternTypesWithExternType(NormalizedExternType& heres, TypeId there);
void unionExternTypes(NormalizedExternType& heres, const NormalizedExternType& theres);
void unionStrings(NormalizedStringType& here, const NormalizedStringType& there);
std::optional<TypePackId> unionOfTypePacks(TypePackId here, TypePackId there);
std::optional<TypeId> unionOfFunctions(TypeId here, TypeId there);
Expand Down Expand Up @@ -423,8 +423,8 @@ class Normalizer
// ------- Normalizing intersections
TypeId intersectionOfTops(TypeId here, TypeId there);
TypeId intersectionOfBools(TypeId here, TypeId there);
void intersectClasses(NormalizedClassType& heres, const NormalizedClassType& theres);
void intersectClassesWithClass(NormalizedClassType& heres, TypeId there);
void intersectExternTypes(NormalizedExternType& heres, const NormalizedExternType& theres);
void intersectExternTypesWithExternType(NormalizedExternType& heres, TypeId there);
void intersectStrings(NormalizedStringType& here, const NormalizedStringType& there);
std::optional<TypePackId> intersectionOfTypePacks(TypePackId here, TypePackId there);
std::optional<TypeId> intersectionOfTables(TypeId here, TypeId there, SeenTablePropPairs& seenTablePropPairs, Set<TypeId>& seenSet);
Expand Down
2 changes: 1 addition & 1 deletion Analysis/include/Luau/Quantify.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct Scope;

void quantify(TypeId ty, TypeLevel level);

// TODO: This is eerily similar to the pattern that NormalizedClassType
// TODO: This is eerily similar to the pattern that NormalizedExternType
// implements. We could, and perhaps should, merge them together.
template<typename K, typename V>
struct OrderedMap
Expand Down
15 changes: 7 additions & 8 deletions Analysis/include/Luau/Subtyping.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct InternalErrorReporter;

class TypeIds;
class Normalizer;
struct NormalizedClassType;
struct NormalizedExternType;
struct NormalizedFunctionType;
struct NormalizedStringType;
struct NormalizedType;
Expand Down Expand Up @@ -121,7 +121,7 @@ struct SubtypingEnvironment
DenseHashMap<TypePackId, TypePackId> mappedGenericPacks{nullptr};

/*
* See the test cyclic_tables_are_assumed_to_be_compatible_with_classes for
* See the test cyclic_tables_are_assumed_to_be_compatible_with_extern_types for
* details.
*
* An empty value is equivalent to a nonexistent key.
Expand Down Expand Up @@ -229,9 +229,8 @@ struct Subtyping
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const TableType* subTable, const TableType* superTable, NotNull<Scope> scope);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const MetatableType* subMt, const MetatableType* superMt, NotNull<Scope> scope);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const MetatableType* subMt, const TableType* superTable, NotNull<Scope> scope);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const ClassType* subClass, const ClassType* superClass, NotNull<Scope> scope);
SubtypingResult
isCovariantWith(SubtypingEnvironment& env, TypeId subTy, const ClassType* subClass, TypeId superTy, const TableType* superTable, NotNull<Scope>);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const ExternType* subExternType, const ExternType* superExternType, NotNull<Scope> scope);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, TypeId subTy, const ExternType* subExternType, TypeId superTy, const TableType* superTable, NotNull<Scope>);
SubtypingResult isCovariantWith(
SubtypingEnvironment& env,
const FunctionType* subFunction,
Expand Down Expand Up @@ -259,11 +258,11 @@ struct Subtyping
);
SubtypingResult isCovariantWith(
SubtypingEnvironment& env,
const NormalizedClassType& subClass,
const NormalizedClassType& superClass,
const NormalizedExternType& subExternType,
const NormalizedExternType& superExternType,
NotNull<Scope> scope
);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const NormalizedClassType& subClass, const TypeIds& superTables, NotNull<Scope> scope);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const NormalizedExternType& subExternType, const TypeIds& superTables, NotNull<Scope> scope);
SubtypingResult isCovariantWith(
SubtypingEnvironment& env,
const NormalizedStringType& subString,
Expand Down
1 change: 1 addition & 0 deletions Analysis/include/Luau/ToString.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct ToStringOptions
bool hideTableKind = false; // If true, all tables will be surrounded with plain '{}'
bool hideNamedFunctionTypeParameters = false; // If true, type parameters of functions will be hidden at top-level.
bool hideFunctionSelfArgument = false; // If true, `self: X` will be omitted from the function signature if the function has self
bool hideTableAliasExpansions = false; // If true, all table aliases will not be expanded
bool useQuestionMarks = true; // If true, use a postfix ? for options, else write them out as unions that include nil.
size_t maxTableLength = size_t(FInt::LuauTableTypeMaximumStringifierLength); // Only applied to TableTypes
size_t maxTypeLength = size_t(FInt::LuauTypeMaximumStringifierLength);
Expand Down
Loading