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/620 #1223

Merged
merged 73 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
73 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
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
36 changes: 25 additions & 11 deletions Analysis/include/Luau/Normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ struct NormalizedFunctionType
struct NormalizedType;
using NormalizedTyvars = std::unordered_map<TypeId, std::unique_ptr<NormalizedType>>;

// Operations provided by `Normalizer` can have ternary results:
// 1. The operation returned true.
// 2. The operation returned false.
// 3. They can hit resource limitations, which invalidates _all normalized types_.
enum class NormalizationResult
{
// The operation returned true or succeeded.
True,
// The operation returned false or failed.
False,
// Resource limits were hit, invalidating all normalized types.
HitLimits,
};

// 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)
// * T is a union of table types
Expand Down Expand Up @@ -366,8 +380,8 @@ class Normalizer
void unionFunctions(NormalizedFunctionType& heress, const NormalizedFunctionType& theress);
void unionTablesWithTable(TypeIds& heres, TypeId there);
void unionTables(TypeIds& heres, const TypeIds& theres);
bool unionNormals(NormalizedType& here, const NormalizedType& there, int ignoreSmallerTyvars = -1);
bool unionNormalWithTy(NormalizedType& here, TypeId there, Set<TypeId>& seenSetTypes, int ignoreSmallerTyvars = -1);
NormalizationResult unionNormals(NormalizedType& here, const NormalizedType& there, int ignoreSmallerTyvars = -1);
NormalizationResult unionNormalWithTy(NormalizedType& here, TypeId there, Set<TypeId>& seenSetTypes, int ignoreSmallerTyvars = -1);

// ------- Negations
std::optional<NormalizedType> negateNormal(const NormalizedType& here);
Expand All @@ -389,19 +403,19 @@ class Normalizer
std::optional<TypeId> intersectionOfFunctions(TypeId here, TypeId there);
void intersectFunctionsWithFunction(NormalizedFunctionType& heress, TypeId there);
void intersectFunctions(NormalizedFunctionType& heress, const NormalizedFunctionType& theress);
bool intersectTyvarsWithTy(NormalizedTyvars& here, TypeId there, Set<TypeId>& seenSetTypes);
bool intersectNormals(NormalizedType& here, const NormalizedType& there, int ignoreSmallerTyvars = -1);
bool intersectNormalWithTy(NormalizedType& here, TypeId there, Set<TypeId>& seenSetTypes);
bool normalizeIntersections(const std::vector<TypeId>& intersections, NormalizedType& outType);
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);

// Check for inhabitance
bool isInhabited(TypeId ty);
bool isInhabited(TypeId ty, Set<TypeId>& seen);
bool isInhabited(const NormalizedType* norm);
bool isInhabited(const NormalizedType* norm, Set<TypeId>& seen);
NormalizationResult isInhabited(TypeId ty);
NormalizationResult isInhabited(TypeId ty, Set<TypeId>& seen);
NormalizationResult isInhabited(const NormalizedType* norm);
NormalizationResult isInhabited(const NormalizedType* norm, Set<TypeId>& seen);

// Check for intersections being inhabited
bool isIntersectionInhabited(TypeId left, TypeId right);
NormalizationResult isIntersectionInhabited(TypeId left, TypeId right);

// -------- Convert back from a normalized type to a type
TypeId typeFromNormal(const NormalizedType& norm);
Expand Down
10 changes: 9 additions & 1 deletion Analysis/include/Luau/Subtyping.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ struct SubtypingEnvironment
DenseHashMap<TypeId, GenericBounds> mappedGenerics{nullptr};
DenseHashMap<TypePackId, TypePackId> mappedGenericPacks{nullptr};

/*
* See the test cyclic_tables_are_assumed_to_be_compatible_with_classes for
* details.
*
* An empty value is equivalent to a nonexistent key.
*/
DenseHashMap<TypeId, TypeId> substitutions{nullptr};

DenseHashMap<std::pair<TypeId, TypeId>, SubtypingResult, TypePairHash> ephemeralCache{{}};

/// Applies `mappedGenerics` to the given type.
Expand Down Expand Up @@ -192,7 +200,7 @@ struct Subtyping
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const MetatableType* subMt, const MetatableType* superMt);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const MetatableType* subMt, const TableType* superTable);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const ClassType* subClass, const ClassType* superClass);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const ClassType* subClass, const TableType* superTable);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, TypeId subTy, const ClassType* subClass, TypeId superTy, const TableType* superTable);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const FunctionType* subFunction, const FunctionType* superFunction);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const PrimitiveType* subPrim, const TableType* superTable);
SubtypingResult isCovariantWith(SubtypingEnvironment& env, const SingletonType* subSingleton, const TableType* superTable);
Expand Down
14 changes: 5 additions & 9 deletions Analysis/src/Autocomplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <utility>

LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution);
LUAU_FASTFLAGVARIABLE(LuauAutocompleteStringLiteralBounds, false);

static const std::unordered_set<std::string> kStatementStartingKeywords = {
"while", "if", "local", "repeat", "function", "do", "for", "return", "break", "continue", "type", "export"};
Expand Down Expand Up @@ -465,15 +464,12 @@ AutocompleteEntryMap autocompleteModuleTypes(const Module& module, Position posi

static void autocompleteStringSingleton(TypeId ty, bool addQuotes, AstNode* node, Position position, AutocompleteEntryMap& result)
{
if (FFlag::LuauAutocompleteStringLiteralBounds)
if (position == node->location.begin || position == node->location.end)
{
if (position == node->location.begin || position == node->location.end)
{
if (auto str = node->as<AstExprConstantString>(); str && str->quoteStyle == AstExprConstantString::Quoted)
return;
else if (node->is<AstExprInterpString>())
return;
}
if (auto str = node->as<AstExprConstantString>(); str && str->quoteStyle == AstExprConstantString::Quoted)
return;
else if (node->is<AstExprInterpString>())
return;
}

auto formatKey = [addQuotes](const std::string& key) {
Expand Down
14 changes: 9 additions & 5 deletions Analysis/src/ConstraintGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,18 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatLocal* stat
scope->lvalueTypes[def] = assignee;
}

TypePackId resultPack = checkPack(scope, statLocal->values, expectedTypes).tp;
addConstraint(scope, statLocal->location, UnpackConstraint{arena->addTypePack(std::move(assignees)), resultPack, /*resultIsLValue*/ true});
TypePackId rvaluePack = checkPack(scope, statLocal->values, expectedTypes).tp;

// Types must flow between whatever annotations were provided and the rhs expression.
if (hasAnnotation)
addConstraint(scope, statLocal->location, PackSubtypeConstraint{resultPack, arena->addTypePack(std::move(annotatedTypes))});
{
TypePackId annotatedPack = arena->addTypePack(std::move(annotatedTypes));
addConstraint(scope, statLocal->location, UnpackConstraint{arena->addTypePack(std::move(assignees)), annotatedPack, /*resultIsLValue*/ true});
addConstraint(scope, statLocal->location, PackSubtypeConstraint{rvaluePack, annotatedPack});
}
else
addConstraint(scope, statLocal->location, UnpackConstraint{arena->addTypePack(std::move(assignees)), rvaluePack, /*resultIsLValue*/ true});

if (statLocal->vars.size == 1 && statLocal->values.size == 1 && firstValueType && scope.get() == rootScope)
if (statLocal->vars.size == 1 && statLocal->values.size == 1 && firstValueType && scope.get() == rootScope && !hasAnnotation)
{
AstLocal* var = statLocal->vars.data[0];
AstExpr* value = statLocal->values.data[0];
Expand Down
10 changes: 4 additions & 6 deletions Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <utility>

LUAU_FASTFLAGVARIABLE(DebugLuauLogSolver, false);

LUAU_FASTFLAGVARIABLE(DebugLuauLogBindings, false);
LUAU_FASTINTVARIABLE(LuauSolverRecursionLimit, 500);

namespace Luau
Expand Down Expand Up @@ -465,10 +465,8 @@ void ConstraintSolver::run()
reduceFamilies(instance, Location{}, TypeFamilyContext{arena, builtinTypes, rootScope, normalizer, NotNull{&iceReporter}, NotNull{&limits}}, false);
}

if (FFlag::DebugLuauLogSolver)
{
if (FFlag::DebugLuauLogSolver || FFlag::DebugLuauLogBindings)
dumpBindings(rootScope, opts);
}

if (logger)
{
Expand Down Expand Up @@ -1761,7 +1759,7 @@ bool ConstraintSolver::tryDispatchUnpack1(NotNull<const Constraint> constraint,
else
{
LUAU_ASSERT(resultIsLValue);
unify(constraint, resultTy, srcTy);
unify(constraint, srcTy, resultTy);
}

unblock(resultTy, constraint->location);
Expand Down Expand Up @@ -1812,7 +1810,7 @@ bool ConstraintSolver::tryDispatch(const UnpackConstraint& c, NotNull<const Cons
tryDispatchUnpack1(constraint, resultTy, srcTy, c.resultIsLValue);
}
else
unify(constraint, resultTy, srcTy);
unify(constraint, srcTy, resultTy);

++resultIter;
++i;
Expand Down
4 changes: 2 additions & 2 deletions Analysis/src/EmbeddedBuiltinDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ type DateTypeResult = {
}

declare os: {
time: @checked (time: DateTypeArg?) -> number,
time: (time: DateTypeArg?) -> number,
date: ((formatString: "*t" | "!*t", time: number?) -> DateTypeResult) & ((formatString: string?, time: number?) -> string),
difftime: @checked (t2: DateTypeResult | number, t1: DateTypeResult | number) -> number,
difftime: (t2: DateTypeResult | number, t1: DateTypeResult | number) -> number,
clock: () -> number,
}

Expand Down
10 changes: 9 additions & 1 deletion Analysis/src/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJson, false)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJsonFile, false)
LUAU_FASTFLAGVARIABLE(DebugLuauForbidInternalTypes, false)
LUAU_FASTFLAGVARIABLE(DebugLuauForceStrictMode, false)
LUAU_FASTFLAGVARIABLE(DebugLuauForceNonStrictMode, false)

namespace Luau
{
Expand Down Expand Up @@ -891,7 +893,13 @@ void Frontend::checkBuildQueueItem(BuildQueueItem& item)
SourceNode& sourceNode = *item.sourceNode;
const SourceModule& sourceModule = *item.sourceModule;
const Config& config = item.config;
Mode mode = sourceModule.mode.value_or(config.mode);
Mode mode;
if (FFlag::DebugLuauForceStrictMode)
mode = Mode::Strict;
else if (FFlag::DebugLuauForceNonStrictMode)
mode = Mode::Nonstrict;
else
mode = sourceModule.mode.value_or(config.mode);
ScopePtr environmentScope = item.environmentScope;
double timestamp = getTimestamp();
const std::vector<RequireCycle>& requireCycles = item.requireCycles;
Expand Down
Loading
Loading