Skip to content
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

Sync to upstream/release/625 #1252

Merged
merged 90 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
a0b9950
Sync to upstream/release/602
aatxe Nov 3, 2023
efe133a
Merge branch 'upstream' into merge
aatxe Nov 3, 2023
4b68791
Sync to upstream/release/603
alexmccord Nov 10, 2023
6343648
Merge branch 'master' into merge
alexmccord Nov 10, 2023
e57cbf6
Merge branch 'heads/upstream' into merge
alexmccord Nov 10, 2023
674c6c4
Sync to upstream/release/604
andyfriesen Nov 17, 2023
4320153
Merge branch 'master' into merge
andyfriesen Nov 17, 2023
2d4a544
Merge branch 'upstream' into merge
andyfriesen Nov 17, 2023
557e77a
VM
Vighnesh-V Dec 2, 2023
98d2db7
add stdint import
Vighnesh-V Dec 2, 2023
e70eec0
Merge branch 'upstream' into merge
Vighnesh-V Dec 2, 2023
7985414
resolve one last merge conflict
Vighnesh-V Dec 2, 2023
c592f50
can CI handle this?
Vighnesh-V Dec 2, 2023
41669c9
Sync to upstream/release/605
Vighnesh-V Dec 2, 2023
c932b8e
remove tests for require by string
Vighnesh-V Dec 2, 2023
c48ffc3
endif
Vighnesh-V Dec 2, 2023
69728e8
Sync to upstream/release/606
vegorov-rbx Dec 8, 2023
f5441d7
Merge branch 'master' into merge
vegorov-rbx Dec 8, 2023
6068432
Merge branch 'upstream' into merge
vegorov-rbx Dec 8, 2023
139b169
Merge fix
vegorov-rbx Dec 8, 2023
f9c5cdd
Sync to upstream/release/607
aatxe Dec 15, 2023
89090a1
Merge branch 'master' into merge
aatxe Dec 15, 2023
d622618
Merge branch 'upstream' into merge
aatxe Dec 15, 2023
adea0f8
fix ubuntu build with import for cstddef in DenseHash
aatxe Dec 15, 2023
d4883bf
Merge branch 'upstream' of https://github.com/luau-lang/luau into ups…
Vighnesh-V Jan 11, 2024
0d5c842
Sync to upstream/release/608
Vighnesh-V Jan 12, 2024
74b0d00
Merge branch 'master' into merge
Vighnesh-V Jan 12, 2024
7932835
Merge branch 'upstream' into merge
Vighnesh-V Jan 12, 2024
50b4779
Sync to upstream/release/608
Vighnesh-V Jan 12, 2024
2f7509d
Merge branch 'upstream' into merge
Vighnesh-V Jan 12, 2024
38aa074
resolve memory leak in VecDeque
Vighnesh-V Jan 12, 2024
064d845
Sync to upstream/release/609
vegorov-rbx Jan 19, 2024
59a29fd
Merge branch 'master' into merge
vegorov-rbx Jan 19, 2024
2fd3da3
Merge branch 'upstream' into merge
vegorov-rbx Jan 19, 2024
0edacdd
Sync to upstream/release/610
aatxe Jan 27, 2024
e3aba92
Merge branch 'master' into merge
aatxe Jan 27, 2024
ce2665d
Merge branch 'upstream' into merge
aatxe Jan 27, 2024
dfa512b
Sync to upstream/release/611
alexmccord Feb 2, 2024
f8f0dd9
Merge branch 'master' into merge
alexmccord Feb 2, 2024
88d2b93
Merge branch 'heads/upstream' into merge
alexmccord Feb 2, 2024
5559c7f
Fix the stack-use-after-scope.
alexmccord Feb 2, 2024
1a6da94
Sync to upstream/release/612
andyfriesen Feb 9, 2024
45e72ee
Merge branch 'master' into merge
andyfriesen Feb 9, 2024
ffd9f32
Merge branch 'upstream' into merge
andyfriesen Feb 9, 2024
158d60c
Sync to upstream/release/613
vegorov-rbx Feb 16, 2024
1778950
Merge branch 'master' into merge
vegorov-rbx Feb 16, 2024
b5f2813
Merge branch 'upstream' into merge
vegorov-rbx Feb 16, 2024
22686ef
Sync to upstream/release/614
Vighnesh-V Feb 23, 2024
ccb5385
Merge branch 'master' into merge
Vighnesh-V Feb 23, 2024
0ab33af
Merge branch 'upstream' into merge
Vighnesh-V Feb 23, 2024
d4a2665
Sync to upstream/release/615
vegorov-rbx Mar 1, 2024
532fd10
Merge branch 'master' into merge
vegorov-rbx Mar 1, 2024
f36cae2
Merge branch 'upstream' into merge
vegorov-rbx Mar 1, 2024
ed4ce84
Merge fixes
vegorov-rbx Mar 1, 2024
27a05c0
Sync to upstream/release/616
aatxe Mar 8, 2024
9e1a26c
Merge branch 'master' into merge
aatxe Mar 8, 2024
1ebdfe0
Merge branch 'upstream' into merge
aatxe Mar 9, 2024
f27d4f5
Sync to upstream/release/617
alexmccord Mar 15, 2024
5e9a567
Merge branch 'master' into merge
alexmccord Mar 15, 2024
c1bbf1e
Merge branch 'heads/upstream' into merge
alexmccord Mar 15, 2024
6fff08b
Sync to upstream/release/618
andyfriesen Mar 22, 2024
a30b2ae
Merge branch 'master' into merge
andyfriesen Mar 22, 2024
4931165
Merge branch 'upstream' into merge
andyfriesen Mar 22, 2024
d8f49d6
Compiler fixes for MSVC and GCC.
andyfriesen Mar 22, 2024
fb90dc0
Sync with upstream/release/620
AmaranthineCodices Mar 30, 2024
77598ed
Merge branch 'master' into merge
AmaranthineCodices Mar 30, 2024
3e1b413
Merge branch 'upstream' into merge
AmaranthineCodices Mar 30, 2024
c730a51
Sync to upstream/release/620
Vighnesh-V Apr 5, 2024
6bef0b1
Merge branch 'master' into merge
Vighnesh-V Apr 5, 2024
2e1c040
Merge branch 'upstream' into merge
Vighnesh-V Apr 5, 2024
9cb93a9
manually fix cmake configuration error
Vighnesh-V Apr 5, 2024
0f19739
remove trailing .
Vighnesh-V Apr 5, 2024
5aa6d99
transplant game engine fix for memory safety issues in normalization …
Vighnesh-V Apr 5, 2024
0f0c0e4
Sync to upstream/release/621
vegorov-rbx Apr 12, 2024
7c346a0
Merge branch 'master' into merge
vegorov-rbx Apr 12, 2024
f97e96d
Merge branch 'upstream' into merge
vegorov-rbx Apr 12, 2024
858b93a
Sync fixup
vegorov-rbx Apr 12, 2024
67b9145
Sync to upstream/release/622
aatxe Apr 19, 2024
5cf508a
Merge branch 'master' into merge
aatxe Apr 19, 2024
641e9f6
Merge branch 'upstream' into merge
aatxe Apr 19, 2024
50a2f8d
Sync to upstream/release/623
alexmccord Apr 25, 2024
8d0a650
Merge branch 'master' into merge
alexmccord Apr 25, 2024
76ed1a5
Merge branch 'heads/upstream' into merge
alexmccord Apr 25, 2024
88dd289
Fix missing include.
alexmccord Apr 25, 2024
93468ca
Sync to upstream/release/624
andyfriesen May 3, 2024
f4ecf43
Merge branch 'master' into merge
andyfriesen May 3, 2024
1ad7b9c
Merge branch 'upstream' into merge
andyfriesen May 3, 2024
9bce20c
Sync to upstream/release/625
Vighnesh-V May 10, 2024
f76a99b
Merge branch 'master' into merge
Vighnesh-V May 10, 2024
f172471
Merge branch 'upstream' into merge
Vighnesh-V May 10, 2024
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: 3 additions & 1 deletion Analysis/include/Luau/Constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,13 @@ struct Constraint

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

DenseHashSet<TypeId> getFreeTypes() const;
DenseHashSet<TypeId> getMaybeMutatedFreeTypes() const;
};

using ConstraintPtr = std::unique_ptr<Constraint>;

bool isReferenceCountedType(const TypeId typ);

inline Constraint& asMutable(const Constraint& c)
{
return const_cast<Constraint&>(c);
Expand Down
18 changes: 18 additions & 0 deletions Analysis/include/Luau/ConstraintSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,24 @@ struct ConstraintSolver
void reportError(TypeErrorData&& data, const Location& location);
void reportError(TypeError e);

/**
* Shifts the count of references from `source` to `target`. This should be paired
* with any instance of binding a free type in order to maintain accurate refcounts.
* If `target` is not a free type, this is a noop.
* @param source the free type which is being bound
* @param target the type which the free type is being bound to
*/
void shiftReferences(TypeId source, TypeId target);

/**
* Generalizes the given free type if the reference counting allows it.
* @param the scope to generalize in
* @param type the free type we want to generalize
* @returns a non-free type that generalizes the argument, or `std::nullopt` if one
* does not exist
*/
std::optional<TypeId> generalizeFreeType(NotNull<Scope> scope, TypeId type);

/**
* Checks the existing set of constraints to see if there exist any that contain
* the provided free type, indicating that it is not yet ready to be replaced by
Expand Down
13 changes: 8 additions & 5 deletions Analysis/include/Luau/Normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ struct NormalizedType
/// Returns true if the type is a subtype of string(it could be a singleton). Behaves like Type::isString()
bool isSubtypeOfString() const;

/// Returns true if the type is a subtype of boolean(it could be a singleton). Behaves like Type::isBoolean()
bool isSubtypeOfBooleans() const;

/// Returns true if this type should result in error suppressing behavior.
bool shouldSuppressErrors() const;

Expand Down Expand Up @@ -360,7 +363,6 @@ class Normalizer
Normalizer& operator=(Normalizer&) = delete;

// If this returns null, the typechecker should emit a "too complex" error
const NormalizedType* DEPRECATED_normalize(TypeId ty);
std::shared_ptr<const NormalizedType> normalize(TypeId ty);
void clearNormal(NormalizedType& norm);

Expand Down Expand Up @@ -395,7 +397,7 @@ class Normalizer
TypeId negate(TypeId there);
void subtractPrimitive(NormalizedType& here, TypeId ty);
void subtractSingleton(NormalizedType& here, TypeId ty);
NormalizationResult intersectNormalWithNegationTy(TypeId toNegate, NormalizedType& intersect, bool useDeprecated = false);
NormalizationResult intersectNormalWithNegationTy(TypeId toNegate, NormalizedType& intersect);

// ------- Normalizing intersections
TypeId intersectionOfTops(TypeId here, TypeId there);
Expand All @@ -404,16 +406,16 @@ class Normalizer
void intersectClassesWithClass(NormalizedClassType& 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);
void intersectTablesWithTable(TypeIds& heres, TypeId there);
std::optional<TypeId> intersectionOfTables(TypeId here, TypeId there, Set<TypeId>& seenSet);
void intersectTablesWithTable(TypeIds& heres, TypeId there, Set<TypeId>& seenSetTypes);
void intersectTables(TypeIds& heres, const TypeIds& theres);
std::optional<TypeId> intersectionOfFunctions(TypeId here, TypeId there);
void intersectFunctionsWithFunction(NormalizedFunctionType& heress, TypeId there);
void intersectFunctions(NormalizedFunctionType& heress, const NormalizedFunctionType& theress);
NormalizationResult intersectTyvarsWithTy(NormalizedTyvars& here, TypeId there, Set<TypeId>& seenSetTypes);
NormalizationResult intersectNormals(NormalizedType& here, const NormalizedType& there, int ignoreSmallerTyvars = -1);
NormalizationResult intersectNormalWithTy(NormalizedType& here, TypeId there, Set<TypeId>& seenSetTypes);
NormalizationResult normalizeIntersections(const std::vector<TypeId>& intersections, NormalizedType& outType);
NormalizationResult normalizeIntersections(const std::vector<TypeId>& intersections, NormalizedType& outType, Set<TypeId>& seenSet);

// Check for inhabitance
NormalizationResult isInhabited(TypeId ty);
Expand All @@ -423,6 +425,7 @@ class Normalizer

// Check for intersections being inhabited
NormalizationResult isIntersectionInhabited(TypeId left, TypeId right);
NormalizationResult isIntersectionInhabited(TypeId left, TypeId right, Set<TypeId>& seenSet);

// -------- Convert back from a normalized type to a type
TypeId typeFromNormal(const NormalizedType& norm);
Expand Down
8 changes: 2 additions & 6 deletions Analysis/include/Luau/Set.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "Luau/Common.h"
#include "Luau/DenseHash.h"

LUAU_FASTFLAG(LuauFixSetIter)
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)

namespace Luau
Expand Down Expand Up @@ -143,11 +142,8 @@ class Set
: impl(impl_)
, end(end_)
{
if (FFlag::LuauFixSetIter || FFlag::DebugLuauDeferredConstraintResolution)
{
while (impl != end && impl->second == false)
++impl;
}
while (impl != end && impl->second == false)
++impl;
}

const T& operator*() const
Expand Down
5 changes: 5 additions & 0 deletions Analysis/include/Luau/Unifier2.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ struct Unifier2
bool unify(TableType* subTable, const TableType* superTable);
bool unify(const MetatableType* subMetatable, const MetatableType* superMetatable);

bool unify(const AnyType* subAny, const FunctionType* superFn);
bool unify(const FunctionType* subFn, const AnyType* superAny);
bool unify(const AnyType* subAny, const TableType* superTable);
bool unify(const TableType* subTable, const AnyType* superAny);

// TODO think about this one carefully. We don't do unions or intersections of type packs
bool unify(TypePackId subTp, TypePackId superTp);

Expand Down
102 changes: 90 additions & 12 deletions Analysis/src/Constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Constraint::Constraint(NotNull<Scope> scope, const Location& location, Constrain
{
}

struct FreeTypeCollector : TypeOnceVisitor
struct ReferenceCountInitializer : TypeOnceVisitor
{

DenseHashSet<TypeId>* result;

FreeTypeCollector(DenseHashSet<TypeId>* result)
ReferenceCountInitializer(DenseHashSet<TypeId>* result)
: result(result)
{
}
Expand All @@ -29,33 +29,111 @@ struct FreeTypeCollector : TypeOnceVisitor
return false;
}

bool visit(TypeId ty, const BlockedType&) override
{
result->insert(ty);
return false;
}

bool visit(TypeId ty, const PendingExpansionType&) override
{
result->insert(ty);
return false;
}

bool visit(TypeId ty, const ClassType&) override
{
// ClassTypes never contain free types.
return false;
}
};

DenseHashSet<TypeId> Constraint::getFreeTypes() const
bool isReferenceCountedType(const TypeId typ)
{
// n.b. this should match whatever `ReferenceCountInitializer` includes.
return get<FreeType>(typ) || get<BlockedType>(typ) || get<PendingExpansionType>(typ);
}

DenseHashSet<TypeId> Constraint::getMaybeMutatedFreeTypes() const
{
DenseHashSet<TypeId> types{{}};
FreeTypeCollector ftc{&types};
ReferenceCountInitializer rci{&types};

if (auto sc = get<SubtypeConstraint>(*this))
if (auto ec = get<EqualityConstraint>(*this))
{
rci.traverse(ec->resultType);
// `EqualityConstraints` should not mutate `assignmentType`.
}
else if (auto sc = get<SubtypeConstraint>(*this))
{
ftc.traverse(sc->subType);
ftc.traverse(sc->superType);
rci.traverse(sc->subType);
rci.traverse(sc->superType);
}
else if (auto psc = get<PackSubtypeConstraint>(*this))
{
ftc.traverse(psc->subPack);
ftc.traverse(psc->superPack);
rci.traverse(psc->subPack);
rci.traverse(psc->superPack);
}
else if (auto gc = get<GeneralizationConstraint>(*this))
{
rci.traverse(gc->generalizedType);
// `GeneralizationConstraints` should not mutate `sourceType` or `interiorTypes`.
}
else if (auto itc = get<IterableConstraint>(*this))
{
rci.traverse(itc->variables);
// `IterableConstraints` should not mutate `iterator`.
}
else if (auto nc = get<NameConstraint>(*this))
{
rci.traverse(nc->namedType);
}
else if (auto taec = get<TypeAliasExpansionConstraint>(*this))
{
rci.traverse(taec->target);
}
else if (auto ptc = get<PrimitiveTypeConstraint>(*this))
{
// we need to take into account primitive type constraints to prevent type families from reducing on
// primitive whose types we have not yet selected to be singleton or not.
ftc.traverse(ptc->freeType);
rci.traverse(ptc->freeType);
}
else if (auto hpc = get<HasPropConstraint>(*this))
{
rci.traverse(hpc->resultType);
// `HasPropConstraints` should not mutate `subjectType`.
}
else if (auto spc = get<SetPropConstraint>(*this))
{
rci.traverse(spc->resultType);
// `SetPropConstraints` should not mutate `subjectType` or `propType`.
// TODO: is this true? it "unifies" with `propType`, so maybe mutates that one too?
}
else if (auto hic = get<HasIndexerConstraint>(*this))
{
rci.traverse(hic->resultType);
// `HasIndexerConstraint` should not mutate `subjectType` or `indexType`.
}
else if (auto sic = get<SetIndexerConstraint>(*this))
{
rci.traverse(sic->propType);
// `SetIndexerConstraints` should not mutate `subjectType` or `indexType`.
}
else if (auto uc = get<UnpackConstraint>(*this))
{
rci.traverse(uc->resultPack);
// `UnpackConstraint` should not mutate `sourcePack`.
}
else if (auto u1c = get<Unpack1Constraint>(*this))
{
rci.traverse(u1c->resultType);
// `Unpack1Constraint` should not mutate `sourceType`.
}
else if (auto rc = get<ReduceConstraint>(*this))
{
rci.traverse(rc->ty);
}
else if (auto rpc = get<ReducePackConstraint>(*this))
{
rci.traverse(rpc->tp);
}

return types;
Expand Down
Loading
Loading