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/568 #865

Merged
merged 92 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
c6ac06e
Sync to upstream/release/543
zeux Sep 1, 2022
75b8a2a
Merge branch 'upstream' into merge
zeux Sep 1, 2022
dec4b67
Sync to upstream/release/544
zeux Sep 8, 2022
ff18a63
Merge branch 'master' into merge
zeux Sep 8, 2022
71df988
Merge branch 'upstream' into merge
zeux Sep 8, 2022
6c70897
Patch the test for now to work with 16K pages
zeux Sep 8, 2022
dd710f6
Sync to upstream/release/545
zeux Sep 15, 2022
19ac72a
Merge branch 'master' into merge
zeux Sep 15, 2022
6e957a4
Merge branch 'upstream' into merge
zeux Sep 15, 2022
48fb5a3
Sync to upstream/release/546
zeux Sep 23, 2022
cd66ad6
Merge branch 'master' into merge
zeux Sep 23, 2022
7bea908
Merge branch 'upstream' into merge
zeux Sep 23, 2022
4176e1c
Fix internals library
zeux Sep 23, 2022
d0989b9
Sync to upstream/release/547
zeux Sep 29, 2022
123649d
Merge branch 'master' into merge
zeux Sep 29, 2022
ebf252f
Merge branch 'upstream' into merge
zeux Sep 29, 2022
91e144a
Sync to upstream/release/548
zeux Oct 6, 2022
9bfe2b8
Merge branch 'master' into merge
zeux Oct 6, 2022
4a79c7f
Merge branch 'upstream' into merge
zeux Oct 6, 2022
d82e736
Sync to upstream/release/549
vegorov-rbx Oct 13, 2022
6aafd2b
Merge branch 'master' into merge
vegorov-rbx Oct 13, 2022
1dca05d
Merge branch 'upstream' into merge
vegorov-rbx Oct 13, 2022
48fd16d
Fix build error
vegorov-rbx Oct 14, 2022
6a98d15
Responding to PR comments
vegorov-rbx Oct 14, 2022
2eff6cf
Sync to upstream/release/550
andyfriesen Oct 21, 2022
72fdf6f
Merge branch 'master' into merge
andyfriesen Oct 21, 2022
b9451c6
Merge branch 'upstream' into merge
andyfriesen Oct 21, 2022
99c0db3
Sync to upstream/release/551
vegorov-rbx Oct 27, 2022
dbedb3c
Merge remote-tracking branch 'upstream/master' into merge
vegorov-rbx Oct 27, 2022
b4b125c
Merge branch 'upstream' into merge
vegorov-rbx Oct 27, 2022
a6cbb0f
Fix clang-14 / GNU ld interaction for target_clones
zeux Oct 28, 2022
e3fdab3
Sync to upstream/release/552
andyfriesen Nov 4, 2022
d189305
Merge branch 'master' into merge
andyfriesen Nov 4, 2022
8fd7d22
Merge branch 'upstream' into merge
andyfriesen Nov 4, 2022
3155ba0
Sync to upstream/release/553
vegorov-rbx Nov 10, 2022
3289fc1
Merge remote-tracking branch 'upstream/master' into merge
vegorov-rbx Nov 10, 2022
2b36613
Merge branch 'upstream' into merge
vegorov-rbx Nov 10, 2022
f521695
Sync to upstream/release/554
andyfriesen Nov 18, 2022
d5ff348
Merge remote-tracking branch 'origin/master' into merge
andyfriesen Nov 18, 2022
3ac3798
Merge branch 'upstream' into merge
andyfriesen Nov 18, 2022
fc45969
Sync to upstream/release/555
vegorov-rbx Dec 2, 2022
471ec75
Merge branch 'master' into merge
vegorov-rbx Dec 2, 2022
621d21d
Merge branch 'upstream' into merge
vegorov-rbx Dec 2, 2022
f10b294
What even is this
vegorov-rbx Dec 2, 2022
6cd507d
Work-around for gcc
vegorov-rbx Dec 2, 2022
abe6768
Sync to upstream/release/556
andyfriesen Dec 9, 2022
4ba102f
Merge branch 'master' into merge
andyfriesen Dec 9, 2022
1197bcd
Merge branch 'upstream' into merge
andyfriesen Dec 9, 2022
9958d23
Sync to upstream/release/557
vegorov-rbx Jan 3, 2023
11e129f
Merge branch 'master' into merge
vegorov-rbx Jan 3, 2023
c48b4d7
Merge branch 'upstream' into merge
vegorov-rbx Jan 3, 2023
ee364a3
Fixed iterator invalidation issue
vegorov-rbx Jan 3, 2023
1958676
Re-using uncleared normalizer in unsafe
vegorov-rbx Jan 4, 2023
36f5009
Sync to upstream/release/558
vegorov-rbx Jan 6, 2023
5e3fbc4
Merge branch 'master' into merge
vegorov-rbx Jan 6, 2023
cf45ce6
Merge branch 'upstream' into merge
vegorov-rbx Jan 6, 2023
5db9675
Smaller recursion limit to not hit stack overflow in debug on Windows
vegorov-rbx Jan 6, 2023
a2365f2
Fix build warning
vegorov-rbx Jan 6, 2023
96c1caf
Sync to upstream/release/559
andyfriesen Jan 13, 2023
b1000a6
Merge branch 'master' into merge
andyfriesen Jan 13, 2023
efaf15e
Merge branch 'upstream' into merge
andyfriesen Jan 13, 2023
eec289a
Sync to upstream/release/560
vegorov-rbx Jan 20, 2023
652f319
Merge branch 'master' into merge
vegorov-rbx Jan 20, 2023
7a43ae3
Merge branch 'upstream' into merge
vegorov-rbx Jan 20, 2023
b0b7dfb
Fix a few style changes that went out-of-sync
vegorov-rbx Jan 20, 2023
53d03f9
Sync to upstream/release/561
andyfriesen Jan 27, 2023
7c5dd3c
Merge branch 'master' into merge
andyfriesen Jan 27, 2023
a17481b
Merge branch 'upstream' into merge
andyfriesen Jan 27, 2023
b7af49c
Fix signed/unsigned comparison warnings on GCC.
andyfriesen Jan 27, 2023
523db5e
Another GCC fix.
andyfriesen Jan 27, 2023
dba2936
Sync to upstream/release/562
vegorov-rbx Feb 3, 2023
f49f073
Merge branch 'master' into merge
vegorov-rbx Feb 3, 2023
c76dd1c
Merge branch 'upstream' into merge
vegorov-rbx Feb 3, 2023
b388e27
Sync to upstream/release/563
andyfriesen Feb 10, 2023
41ff9cb
Merge branch 'master' into merge
andyfriesen Feb 10, 2023
c3b1945
Merge branch 'upstream' into merge
andyfriesen Feb 10, 2023
5c77305
Sync to upstream/release/564
vegorov-rbx Feb 17, 2023
1f8ec89
Merge branch 'master' into merge
vegorov-rbx Feb 17, 2023
be06c31
Merge branch 'upstream' into merge
vegorov-rbx Feb 17, 2023
1e7b23f
Sync to upstream/release/565
andyfriesen Feb 24, 2023
3974fcc
Merge branch 'master' into merge
andyfriesen Feb 24, 2023
7a822c9
Merge branch 'upstream' into merge
andyfriesen Feb 24, 2023
e58bb1b
GCC fix.
andyfriesen Feb 24, 2023
9a281f0
Sync to upstream/release/566
vegorov-rbx Mar 3, 2023
ca34b44
Merge branch 'master' into merge
vegorov-rbx Mar 3, 2023
ac9718e
Merge branch 'upstream' into merge
vegorov-rbx Mar 3, 2023
4653484
Sync to upstream/release/567
andyfriesen Mar 10, 2023
cfee765
Merge branch 'master' into merge
andyfriesen Mar 10, 2023
a0fe195
Merge branch 'upstream' into merge
andyfriesen Mar 10, 2023
e280064
Sync to upstream/release/568
vegorov-rbx Mar 17, 2023
bbeec10
Merge branch 'master' into merge
vegorov-rbx Mar 17, 2023
1c4d7a6
Merge branch 'upstream' into merge
vegorov-rbx Mar 17, 2023
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
43 changes: 22 additions & 21 deletions Analysis/include/Luau/ConstraintGraphBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#pragma once

#include "Luau/Ast.h"
#include "Luau/Refinement.h"
#include "Luau/Constraint.h"
#include "Luau/ControlFlow.h"
#include "Luau/DataFlowGraph.h"
#include "Luau/Module.h"
#include "Luau/ModuleResolver.h"
#include "Luau/NotNull.h"
#include "Luau/Refinement.h"
#include "Luau/Symbol.h"
#include "Luau/Type.h"
#include "Luau/Variant.h"
Expand Down Expand Up @@ -141,26 +142,26 @@ struct ConstraintGraphBuilder
*/
void visit(AstStatBlock* block);

void visitBlockWithoutChildScope(const ScopePtr& scope, AstStatBlock* block);

void visit(const ScopePtr& scope, AstStat* stat);
void visit(const ScopePtr& scope, AstStatBlock* block);
void visit(const ScopePtr& scope, AstStatLocal* local);
void visit(const ScopePtr& scope, AstStatFor* for_);
void visit(const ScopePtr& scope, AstStatForIn* forIn);
void visit(const ScopePtr& scope, AstStatWhile* while_);
void visit(const ScopePtr& scope, AstStatRepeat* repeat);
void visit(const ScopePtr& scope, AstStatLocalFunction* function);
void visit(const ScopePtr& scope, AstStatFunction* function);
void visit(const ScopePtr& scope, AstStatReturn* ret);
void visit(const ScopePtr& scope, AstStatAssign* assign);
void visit(const ScopePtr& scope, AstStatCompoundAssign* assign);
void visit(const ScopePtr& scope, AstStatIf* ifStatement);
void visit(const ScopePtr& scope, AstStatTypeAlias* alias);
void visit(const ScopePtr& scope, AstStatDeclareGlobal* declareGlobal);
void visit(const ScopePtr& scope, AstStatDeclareClass* declareClass);
void visit(const ScopePtr& scope, AstStatDeclareFunction* declareFunction);
void visit(const ScopePtr& scope, AstStatError* error);
ControlFlow visitBlockWithoutChildScope(const ScopePtr& scope, AstStatBlock* block);

ControlFlow visit(const ScopePtr& scope, AstStat* stat);
ControlFlow visit(const ScopePtr& scope, AstStatBlock* block);
ControlFlow visit(const ScopePtr& scope, AstStatLocal* local);
ControlFlow visit(const ScopePtr& scope, AstStatFor* for_);
ControlFlow visit(const ScopePtr& scope, AstStatForIn* forIn);
ControlFlow visit(const ScopePtr& scope, AstStatWhile* while_);
ControlFlow visit(const ScopePtr& scope, AstStatRepeat* repeat);
ControlFlow visit(const ScopePtr& scope, AstStatLocalFunction* function);
ControlFlow visit(const ScopePtr& scope, AstStatFunction* function);
ControlFlow visit(const ScopePtr& scope, AstStatReturn* ret);
ControlFlow visit(const ScopePtr& scope, AstStatAssign* assign);
ControlFlow visit(const ScopePtr& scope, AstStatCompoundAssign* assign);
ControlFlow visit(const ScopePtr& scope, AstStatIf* ifStatement);
ControlFlow visit(const ScopePtr& scope, AstStatTypeAlias* alias);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareGlobal* declareGlobal);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareClass* declareClass);
ControlFlow visit(const ScopePtr& scope, AstStatDeclareFunction* declareFunction);
ControlFlow visit(const ScopePtr& scope, AstStatError* error);

InferencePack checkPack(const ScopePtr& scope, AstArray<AstExpr*> exprs, const std::vector<std::optional<TypeId>>& expectedTypes = {});
InferencePack checkPack(const ScopePtr& scope, AstExpr* expr, const std::vector<std::optional<TypeId>>& expectedTypes = {});
Expand Down
8 changes: 8 additions & 0 deletions Analysis/include/Luau/ConstraintSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ struct ConstraintSolver
bool block(TypeId target, NotNull<const Constraint> constraint);
bool block(TypePackId target, NotNull<const Constraint> constraint);

/**
* For all constraints that are blocked on one constraint, make them block
* on a new constraint.
* @param source the constraint to copy blocks from.
* @param addition the constraint that other constraints should now block on.
*/
void inheritBlocks(NotNull<const Constraint> source, NotNull<const Constraint> addition);

// Traverse the type. If any blocked or pending types are found, block
// the constraint on them.
//
Expand Down
36 changes: 36 additions & 0 deletions Analysis/include/Luau/ControlFlow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include <memory>

namespace Luau
{

struct Scope;
using ScopePtr = std::shared_ptr<Scope>;

enum class ControlFlow
{
None = 0b00001,
Returns = 0b00010,
Throws = 0b00100,
Break = 0b01000, // Currently unused.
Continue = 0b10000, // Currently unused.
};

inline ControlFlow operator&(ControlFlow a, ControlFlow b)
{
return ControlFlow(int(a) & int(b));
}

inline ControlFlow operator|(ControlFlow a, ControlFlow b)
{
return ControlFlow(int(a) | int(b));
}

inline bool matches(ControlFlow a, ControlFlow b)
{
return (a & b) != ControlFlow(0);
}

} // namespace Luau
12 changes: 10 additions & 2 deletions Analysis/include/Luau/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,21 @@ struct FrontendOptions
// order to get more precise type information)
bool forAutocomplete = false;

bool runLintChecks = false;

// If not empty, randomly shuffle the constraint set before attempting to
// solve. Use this value to seed the random number generator.
std::optional<unsigned> randomizeConstraintResolutionSeed;

std::optional<LintOptions> enabledLintWarnings;
};

struct CheckResult
{
std::vector<TypeError> errors;

LintResult lintResult;

std::vector<ModuleName> timeoutHits;
};

Expand Down Expand Up @@ -133,8 +140,9 @@ struct Frontend

CheckResult check(const ModuleName& name, std::optional<FrontendOptions> optionOverride = {}); // new shininess

LintResult lint(const ModuleName& name, std::optional<LintOptions> enabledLintWarnings = {});
LintResult lint(const SourceModule& module, std::optional<LintOptions> enabledLintWarnings = {});
// Use 'check' with 'runLintChecks' set to true in FrontendOptions (enabledLintWarnings be set there as well)
LintResult lint_DEPRECATED(const ModuleName& name, std::optional<LintOptions> enabledLintWarnings = {});
LintResult lint_DEPRECATED(const SourceModule& module, std::optional<LintOptions> enabledLintWarnings = {});

bool isDirty(const ModuleName& name, bool forAutocomplete = false) const;
void markDirty(const ModuleName& name, std::vector<ModuleName>* markedDirty = nullptr);
Expand Down
2 changes: 2 additions & 0 deletions Analysis/include/Luau/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

#include "Luau/Error.h"
#include "Luau/Linter.h"
#include "Luau/FileResolver.h"
#include "Luau/ParseOptions.h"
#include "Luau/ParseResult.h"
Expand Down Expand Up @@ -88,6 +89,7 @@ struct Module

std::unordered_map<Name, TypeId> declaredGlobals;
ErrorVec errors;
LintResult lintResult;
Mode mode;
SourceCode::Type type;
bool timeout = false;
Expand Down
6 changes: 4 additions & 2 deletions Analysis/include/Luau/Normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ using ModulePtr = std::shared_ptr<Module>;

bool isSubtype(TypeId subTy, TypeId superTy, NotNull<Scope> scope, NotNull<BuiltinTypes> builtinTypes, InternalErrorReporter& ice);
bool isSubtype(TypePackId subTy, TypePackId superTy, NotNull<Scope> scope, NotNull<BuiltinTypes> builtinTypes, InternalErrorReporter& ice);
bool isConsistentSubtype(TypeId subTy, TypeId superTy, NotNull<Scope> scope, NotNull<BuiltinTypes> builtinTypes, InternalErrorReporter& ice);
bool isConsistentSubtype(TypePackId subTy, TypePackId superTy, NotNull<Scope> scope, NotNull<BuiltinTypes> builtinTypes, InternalErrorReporter& ice);

class TypeIds
{
Expand Down Expand Up @@ -203,7 +205,7 @@ struct NormalizedFunctionType
};

// A normalized generic/free type is a union, where each option is of the form (X & T) where
// * X is either a free type or a generic
// * X is either a free type, a generic or a blocked type.
// * T is a normalized type.
struct NormalizedType;
using NormalizedTyvars = std::unordered_map<TypeId, std::unique_ptr<NormalizedType>>;
Expand All @@ -214,7 +216,7 @@ bool isInhabited_DEPRECATED(const NormalizedType& norm);
// * P is a union of primitive types (including singletons, classes 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 normalized types, intersected with a normalized type
// * G is a union of generic/free/blocked types, intersected with a normalized type
struct NormalizedType
{
// The top part of the type.
Expand Down
1 change: 1 addition & 0 deletions Analysis/include/Luau/Scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct Scope

RefinementMap refinements;
DenseHashMap<const Def*, TypeId> dcrRefinements{nullptr};
void inheritRefinements(const ScopePtr& childScope);

// For mutually recursive type aliases, it's important that
// they use the same types for the same names.
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 @@ -102,7 +102,7 @@ struct BlockedType
BlockedType();
int index;

static int nextIndex;
static int DEPRECATED_nextIndex;
};

struct PrimitiveType
Expand Down
43 changes: 22 additions & 21 deletions Analysis/include/Luau/TypeInfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#pragma once

#include "Luau/Anyification.h"
#include "Luau/Predicate.h"
#include "Luau/ControlFlow.h"
#include "Luau/Error.h"
#include "Luau/Module.h"
#include "Luau/Symbol.h"
#include "Luau/Predicate.h"
#include "Luau/Substitution.h"
#include "Luau/Symbol.h"
#include "Luau/TxnLog.h"
#include "Luau/TypePack.h"
#include "Luau/Type.h"
#include "Luau/TypePack.h"
#include "Luau/Unifier.h"
#include "Luau/UnifierSharedState.h"

Expand Down Expand Up @@ -87,28 +88,28 @@ struct TypeChecker

std::vector<std::pair<Location, ScopePtr>> getScopes() const;

void check(const ScopePtr& scope, const AstStat& statement);
void check(const ScopePtr& scope, const AstStatBlock& statement);
void check(const ScopePtr& scope, const AstStatIf& statement);
void check(const ScopePtr& scope, const AstStatWhile& statement);
void check(const ScopePtr& scope, const AstStatRepeat& statement);
void check(const ScopePtr& scope, const AstStatReturn& return_);
void check(const ScopePtr& scope, const AstStatAssign& assign);
void check(const ScopePtr& scope, const AstStatCompoundAssign& assign);
void check(const ScopePtr& scope, const AstStatLocal& local);
void check(const ScopePtr& scope, const AstStatFor& local);
void check(const ScopePtr& scope, const AstStatForIn& forin);
void check(const ScopePtr& scope, TypeId ty, const ScopePtr& funScope, const AstStatFunction& function);
void check(const ScopePtr& scope, TypeId ty, const ScopePtr& funScope, const AstStatLocalFunction& function);
void check(const ScopePtr& scope, const AstStatTypeAlias& typealias);
void check(const ScopePtr& scope, const AstStatDeclareClass& declaredClass);
void check(const ScopePtr& scope, const AstStatDeclareFunction& declaredFunction);
ControlFlow check(const ScopePtr& scope, const AstStat& statement);
ControlFlow check(const ScopePtr& scope, const AstStatBlock& statement);
ControlFlow check(const ScopePtr& scope, const AstStatIf& statement);
ControlFlow check(const ScopePtr& scope, const AstStatWhile& statement);
ControlFlow check(const ScopePtr& scope, const AstStatRepeat& statement);
ControlFlow check(const ScopePtr& scope, const AstStatReturn& return_);
ControlFlow check(const ScopePtr& scope, const AstStatAssign& assign);
ControlFlow check(const ScopePtr& scope, const AstStatCompoundAssign& assign);
ControlFlow check(const ScopePtr& scope, const AstStatLocal& local);
ControlFlow check(const ScopePtr& scope, const AstStatFor& local);
ControlFlow check(const ScopePtr& scope, const AstStatForIn& forin);
ControlFlow check(const ScopePtr& scope, TypeId ty, const ScopePtr& funScope, const AstStatFunction& function);
ControlFlow check(const ScopePtr& scope, TypeId ty, const ScopePtr& funScope, const AstStatLocalFunction& function);
ControlFlow check(const ScopePtr& scope, const AstStatTypeAlias& typealias);
ControlFlow check(const ScopePtr& scope, const AstStatDeclareClass& declaredClass);
ControlFlow check(const ScopePtr& scope, const AstStatDeclareFunction& declaredFunction);

void prototype(const ScopePtr& scope, const AstStatTypeAlias& typealias, int subLevel = 0);
void prototype(const ScopePtr& scope, const AstStatDeclareClass& declaredClass);

void checkBlock(const ScopePtr& scope, const AstStatBlock& statement);
void checkBlockWithoutRecursionCheck(const ScopePtr& scope, const AstStatBlock& statement);
ControlFlow checkBlock(const ScopePtr& scope, const AstStatBlock& statement);
ControlFlow checkBlockWithoutRecursionCheck(const ScopePtr& scope, const AstStatBlock& statement);
void checkBlockTypeAliases(const ScopePtr& scope, std::vector<AstStat*>& sorted);

WithPredicate<TypeId> checkExpr(
Expand Down
2 changes: 2 additions & 0 deletions Analysis/include/Luau/Unifiable.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ namespace Luau::Unifiable

using Name = std::string;

int freshIndex();

struct Free
{
explicit Free(TypeLevel level);
Expand Down
3 changes: 2 additions & 1 deletion Analysis/include/Luau/Unifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct Unifier

NotNull<Scope> scope; // const Scope maybe
TxnLog log;
bool failure = false;
ErrorVec errors;
Location location;
Variance variance = Covariant;
Expand Down Expand Up @@ -93,7 +94,7 @@ struct Unifier

// Traverse the two types provided and block on any BlockedTypes we find.
// Returns true if any types were blocked on.
bool blockOnBlockedTypes(TypeId subTy, TypeId superTy);
bool DEPRECATED_blockOnBlockedTypes(TypeId subTy, TypeId superTy);

void tryUnifyTypeWithUnion(TypeId subTy, TypeId superTy, const UnionType* uv, bool cacheEnabled, bool isFunctionCall);
void tryUnifyTypeWithIntersection(TypeId subTy, TypeId superTy, const IntersectionType* uv);
Expand Down
Loading