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/588 #992

Merged
merged 151 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 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
81200e1
Sync to upstream/release/569
andyfriesen Mar 24, 2023
ce18822
Merge branch 'master' into merge
andyfriesen Mar 24, 2023
c955451
Merge branch 'upstream' into merge
andyfriesen Mar 24, 2023
d1acde3
Sync to upstream/release/570
vegorov-rbx Mar 31, 2023
c6b6ab6
Merge branch 'master' into merge
vegorov-rbx Mar 31, 2023
d70df63
Merge branch 'upstream' into merge
vegorov-rbx Mar 31, 2023
d071e41
g++ build fix
vegorov-rbx Mar 31, 2023
5309401
Sync to upstream/release/571
andyfriesen Apr 7, 2023
97f8bf6
Merge branch 'master' into merge
andyfriesen Apr 7, 2023
395bf5c
Merge branch 'upstream' into merge
andyfriesen Apr 7, 2023
5e771b8
Sync to upstream/release/572
vegorov-rbx Apr 14, 2023
70ef0fb
Merge branch 'master' into merge
vegorov-rbx Apr 14, 2023
1ffbf6c
Merge branch 'upstream' into merge
vegorov-rbx Apr 14, 2023
33b9558
Build fix
vegorov-rbx Apr 14, 2023
d5cdb68
Sync to upstream/release/573
andyfriesen Apr 21, 2023
a0f9842
Merge branch 'master' into merge
andyfriesen Apr 21, 2023
1126490
Merge branch 'upstream' into merge
andyfriesen Apr 21, 2023
1c2ce0d
Sync to upstream/release/574
vegorov-rbx Apr 28, 2023
8bd3714
Merge branch 'master' into merge
vegorov-rbx Apr 28, 2023
348f85c
Merge branch 'upstream' into merge
vegorov-rbx Apr 28, 2023
716f633
Sync to upstream/release/575
andyfriesen May 5, 2023
cc96f86
Merge branch 'master' into merge
andyfriesen May 5, 2023
95f0a04
Merge branch 'upstream' into merge
andyfriesen May 5, 2023
12c1edf
This test fails on a64 so disable it for now.
andyfriesen May 5, 2023
f7c7801
Add pthread as a link dependency to Luau.Analyze.CLI for Linux.
andyfriesen May 5, 2023
3247aab
Sync to upstream/release/576
vegorov-rbx May 12, 2023
38ab2e5
Merge branch 'master' into merge
vegorov-rbx May 12, 2023
59c2698
Merge branch 'upstream' into merge
vegorov-rbx May 12, 2023
eb71060
Sync to upstream/release/577
andyfriesen May 19, 2023
4fb7594
Merge branch 'master' into merge
andyfriesen May 19, 2023
f3a6e37
Merge branch 'upstream' into merge
andyfriesen May 19, 2023
123496b
gcc fix.
andyfriesen May 19, 2023
b8e9d07
Sync to upstream/release/578
vegorov-rbx May 25, 2023
f97a897
Merge branch 'master' into merge
vegorov-rbx May 25, 2023
fc9557d
Merge branch 'upstream' into merge
vegorov-rbx May 25, 2023
f435740
Sync to upstream/release/579
andyfriesen Jun 2, 2023
349d6f4
Merge branch 'master' into merge
andyfriesen Jun 2, 2023
a3d22de
Merge branch 'upstream' into merge
andyfriesen Jun 2, 2023
88cd3dd
Sync to upstream/release/580
vegorov-rbx Jun 9, 2023
ef2e46e
Merge branch 'master' into merge
vegorov-rbx Jun 9, 2023
a9becc9
Merge branch 'upstream' into merge
vegorov-rbx Jun 9, 2023
212888c
Fix build warning
vegorov-rbx Jun 9, 2023
6ee4f19
Sync to upstream/release/581
andyfriesen Jun 16, 2023
f9cfef1
Merge branch 'master' into merge
andyfriesen Jun 16, 2023
00b9898
Merge branch 'upstream' into merge
andyfriesen Jun 16, 2023
8bc2f51
Sync to upstream/release/582
vegorov-rbx Jun 24, 2023
7a2f94a
Merge branch 'master' into merge
vegorov-rbx Jun 24, 2023
e1a7c3b
Merge branch 'upstream' into merge
vegorov-rbx Jun 24, 2023
e00dbbe
Sync to upstream/release/583
andyfriesen Jul 7, 2023
01cbf18
Merge branch 'master' into merge
andyfriesen Jul 7, 2023
b92d4d7
Merge branch 'upstream' into merge
andyfriesen Jul 7, 2023
dc2a1cc
GCC fix.
andyfriesen Jul 7, 2023
b403075
Sync to upstream/release/584
vegorov-rbx Jul 14, 2023
03063d0
Merge branch 'master' into merge
vegorov-rbx Jul 14, 2023
4ffa98f
Merge branch 'upstream' into merge
vegorov-rbx Jul 14, 2023
f16d002
GCC fix
vegorov-rbx Jul 14, 2023
5e1aca1
Sync to upstream/release/588
vegorov-rbx Jul 28, 2023
9fd79ad
Merge branch 'master' into merge
vegorov-rbx Jul 28, 2023
4c6a370
Merge branch 'upstream' into merge
vegorov-rbx Jul 28, 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
7 changes: 7 additions & 0 deletions Analysis/include/Luau/Autocomplete.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum class AutocompleteEntryKind
String,
Type,
Module,
GeneratedFunction,
};

enum class ParenthesesRecommendation
Expand Down Expand Up @@ -70,6 +71,10 @@ struct AutocompleteEntry
std::optional<std::string> documentationSymbol = std::nullopt;
Tags tags;
ParenthesesRecommendation parens = ParenthesesRecommendation::None;
std::optional<std::string> insertText;

// Only meaningful if kind is Property.
bool indexedWithSelf = false;
};

using AutocompleteEntryMap = std::unordered_map<std::string, AutocompleteEntry>;
Expand All @@ -94,4 +99,6 @@ using StringCompletionCallback =

AutocompleteResult autocomplete(Frontend& frontend, const ModuleName& moduleName, Position position, StringCompletionCallback callback);

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

} // namespace Luau
2 changes: 1 addition & 1 deletion Analysis/include/Luau/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Config
{
Config();

Mode mode;
Mode mode = Mode::Nonstrict;

ParseOptions parseOptions;

Expand Down
3 changes: 2 additions & 1 deletion Analysis/include/Luau/ConstraintGraphBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ struct ConstraintGraphBuilder
ScopePtr globalScope;

std::function<void(const ModuleName&, const ScopePtr&)> prepareModuleScope;
std::vector<RequireCycle> requireCycles;

DcrLogger* logger;

ConstraintGraphBuilder(ModulePtr module, TypeArena* arena, NotNull<ModuleResolver> moduleResolver, NotNull<BuiltinTypes> builtinTypes,
NotNull<InternalErrorReporter> ice, const ScopePtr& globalScope, std::function<void(const ModuleName&, const ScopePtr&)> prepareModuleScope,
DcrLogger* logger, NotNull<DataFlowGraph> dfg);
DcrLogger* logger, NotNull<DataFlowGraph> dfg, std::vector<RequireCycle> requireCycles);

/**
* Fabricates a new free type belonging to a given scope.
Expand Down
8 changes: 7 additions & 1 deletion Analysis/include/Luau/ConstraintSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Luau/Normalize.h"
#include "Luau/ToString.h"
#include "Luau/Type.h"
#include "Luau/TypeCheckLimits.h"
#include "Luau/Variant.h"

#include <vector>
Expand Down Expand Up @@ -81,9 +82,11 @@ struct ConstraintSolver
std::vector<RequireCycle> requireCycles;

DcrLogger* logger;
TypeCheckLimits limits;

explicit ConstraintSolver(NotNull<Normalizer> normalizer, NotNull<Scope> rootScope, std::vector<NotNull<Constraint>> constraints,
ModuleName moduleName, NotNull<ModuleResolver> moduleResolver, std::vector<RequireCycle> requireCycles, DcrLogger* logger);
ModuleName moduleName, NotNull<ModuleResolver> moduleResolver, std::vector<RequireCycle> requireCycles, DcrLogger* logger,
TypeCheckLimits limits);

// Randomize the order in which to dispatch constraints
void randomize(unsigned seed);
Expand Down Expand Up @@ -280,6 +283,9 @@ struct ConstraintSolver

TypePackId anyifyModuleReturnTypePackGenerics(TypePackId tp);

void throwTimeLimitError();
void throwUserCancelError();

ToStringOptions opts;
};

Expand Down
20 changes: 16 additions & 4 deletions Analysis/include/Luau/Differ.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include "Luau/DenseHash.h"
#include "Luau/Type.h"
#include <optional>
#include <string>
#include <unordered_map>

namespace Luau
{
Expand All @@ -17,6 +19,7 @@ struct DiffPathNode
FunctionReturn,
Union,
Intersection,
Negation,
};
Kind kind;
// non-null when TableProperty
Expand Down Expand Up @@ -54,18 +57,24 @@ struct DiffPathNodeLeaf
std::optional<Name> tableProperty;
std::optional<int> minLength;
bool isVariadic;
DiffPathNodeLeaf(std::optional<TypeId> ty, std::optional<Name> tableProperty, std::optional<int> minLength, bool isVariadic)
// TODO: Rename to anonymousIndex, for both union and Intersection
std::optional<size_t> unionIndex;
DiffPathNodeLeaf(
std::optional<TypeId> ty, std::optional<Name> tableProperty, std::optional<int> minLength, bool isVariadic, std::optional<size_t> unionIndex)
: ty(ty)
, tableProperty(tableProperty)
, minLength(minLength)
, isVariadic(isVariadic)
, unionIndex(unionIndex)
{
}

static DiffPathNodeLeaf detailsNormal(TypeId ty);

static DiffPathNodeLeaf detailsTableProperty(TypeId ty, Name tableProperty);

static DiffPathNodeLeaf detailsUnionIndex(TypeId ty, size_t index);

static DiffPathNodeLeaf detailsLength(int minLength, bool isVariadic);

static DiffPathNodeLeaf nullopts();
Expand All @@ -82,11 +91,12 @@ struct DiffError
enum Kind
{
Normal,
MissingProperty,
MissingTableProperty,
MissingUnionMember,
MissingIntersectionMember,
IncompatibleGeneric,
LengthMismatchInFnArgs,
LengthMismatchInFnRets,
LengthMismatchInUnion,
LengthMismatchInIntersection,
};
Kind kind;

Expand Down Expand Up @@ -141,6 +151,8 @@ struct DifferEnvironment
{
TypeId rootLeft;
TypeId rootRight;

DenseHashMap<TypeId, TypeId> genericMatchedPairs;
};
DifferResult diff(TypeId ty1, TypeId ty2);

Expand Down
14 changes: 4 additions & 10 deletions Analysis/include/Luau/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Luau/ModuleResolver.h"
#include "Luau/RequireTracer.h"
#include "Luau/Scope.h"
#include "Luau/TypeCheckLimits.h"
#include "Luau/TypeInfer.h"
#include "Luau/Variant.h"

Expand Down Expand Up @@ -189,14 +190,6 @@ struct Frontend
std::optional<CheckResult> getCheckResult(const ModuleName& name, bool accumulateNested, bool forAutocomplete = false);

private:
struct TypeCheckLimits
{
std::optional<double> finishTime;
std::optional<int> instantiationChildLimit;
std::optional<int> unifierIterationLimit;
std::shared_ptr<FrontendCancellationToken> cancellationToken;
};

ModulePtr check(const SourceModule& sourceModule, Mode mode, std::vector<RequireCycle> requireCycles, std::optional<ScopePtr> environmentScope,
bool forAutocomplete, bool recordJsonLog, TypeCheckLimits typeCheckLimits);

Expand Down Expand Up @@ -248,11 +241,12 @@ struct Frontend

ModulePtr check(const SourceModule& sourceModule, const std::vector<RequireCycle>& requireCycles, NotNull<BuiltinTypes> builtinTypes,
NotNull<InternalErrorReporter> iceHandler, NotNull<ModuleResolver> moduleResolver, NotNull<FileResolver> fileResolver,
const ScopePtr& globalScope, std::function<void(const ModuleName&, const ScopePtr&)> prepareModuleScope, FrontendOptions options);
const ScopePtr& globalScope, std::function<void(const ModuleName&, const ScopePtr&)> prepareModuleScope, FrontendOptions options,
TypeCheckLimits limits);

ModulePtr check(const SourceModule& sourceModule, const std::vector<RequireCycle>& requireCycles, NotNull<BuiltinTypes> builtinTypes,
NotNull<InternalErrorReporter> iceHandler, NotNull<ModuleResolver> moduleResolver, NotNull<FileResolver> fileResolver,
const ScopePtr& globalScope, std::function<void(const ModuleName&, const ScopePtr&)> prepareModuleScope, FrontendOptions options,
bool recordJsonLog);
TypeCheckLimits limits, bool recordJsonLog);

} // namespace Luau
3 changes: 3 additions & 0 deletions Analysis/include/Luau/Normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ struct NormalizedType
/// Returns true if this type should result in error suppressing behavior.
bool shouldSuppressErrors() const;

/// Returns true if this type contains the primitve top table type, `table`.
bool hasTopTable() const;

// Helpers that improve readability of the above (they just say if the component is present)
bool hasTops() const;
bool hasBooleans() const;
Expand Down
14 changes: 1 addition & 13 deletions Analysis/include/Luau/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <string>

LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)

namespace Luau
{

Expand Down Expand Up @@ -42,17 +40,7 @@ struct Symbol
return local != nullptr || global.value != nullptr;
}

bool operator==(const Symbol& rhs) const
{
if (local)
return local == rhs.local;
else if (global.value)
return rhs.global.value && global == rhs.global.value; // Subtlety: AstName::operator==(const char*) uses strcmp, not pointer identity.
else if (FFlag::DebugLuauDeferredConstraintResolution)
return !rhs.local && !rhs.global.value; // Reflexivity: we already know `this` Symbol is empty, so check that rhs is.
else
return false;
}
bool operator==(const Symbol& rhs) const;

bool operator!=(const Symbol& rhs) const
{
Expand Down
4 changes: 4 additions & 0 deletions Analysis/include/Luau/TypeArena.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

namespace Luau
{
struct Module;

struct TypeArena
{
TypedAllocator<Type> types;
TypedAllocator<TypePackVar> typePacks;

// Owning module, if any
Module* owningModule = nullptr;

void clear();

template<typename T>
Expand Down
41 changes: 41 additions & 0 deletions Analysis/include/Luau/TypeCheckLimits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once

#include "Luau/Cancellation.h"
#include "Luau/Error.h"

#include <memory>
#include <optional>
#include <string>

namespace Luau
{

class TimeLimitError : public InternalCompilerError
{
public:
explicit TimeLimitError(const std::string& moduleName)
: InternalCompilerError("Typeinfer failed to complete in allotted time", moduleName)
{
}
};

class UserCancelError : public InternalCompilerError
{
public:
explicit UserCancelError(const std::string& moduleName)
: InternalCompilerError("Analysis has been cancelled by user", moduleName)
{
}
};

struct TypeCheckLimits
{
std::optional<double> finishTime;
std::optional<int> instantiationChildLimit;
std::optional<int> unifierIterationLimit;

std::shared_ptr<FrontendCancellationToken> cancellationToken;
};

} // namespace Luau
19 changes: 1 addition & 18 deletions Analysis/include/Luau/TypeInfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Luau/Symbol.h"
#include "Luau/TxnLog.h"
#include "Luau/Type.h"
#include "Luau/TypeCheckLimits.h"
#include "Luau/TypePack.h"
#include "Luau/TypeUtils.h"
#include "Luau/Unifier.h"
Expand Down Expand Up @@ -56,24 +57,6 @@ struct HashBoolNamePair
size_t operator()(const std::pair<bool, Name>& pair) const;
};

class TimeLimitError : public InternalCompilerError
{
public:
explicit TimeLimitError(const std::string& moduleName)
: InternalCompilerError("Typeinfer failed to complete in allotted time", moduleName)
{
}
};

class UserCancelError : public InternalCompilerError
{
public:
explicit UserCancelError(const std::string& moduleName)
: InternalCompilerError("Analysis has been cancelled by user", moduleName)
{
}
};

struct GlobalTypes
{
GlobalTypes(NotNull<BuiltinTypes> builtinTypes);
Expand Down
46 changes: 46 additions & 0 deletions Analysis/include/Luau/TypeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Luau

struct TxnLog;
struct TypeArena;
class Normalizer;

enum class ValueContext
{
Expand Down Expand Up @@ -55,6 +56,51 @@ std::vector<TypeId> reduceUnion(const std::vector<TypeId>& types);
*/
TypeId stripNil(NotNull<BuiltinTypes> builtinTypes, TypeArena& arena, TypeId ty);

enum class ErrorSuppression
{
Suppress,
DoNotSuppress,
NormalizationFailed
};

/**
* Normalizes the given type using the normalizer to determine if the type
* should suppress any errors that would be reported involving it.
* @param normalizer the normalizer to use
* @param ty the type to check for error suppression
* @returns an enum indicating whether or not to suppress the error or to signal a normalization failure
*/
ErrorSuppression shouldSuppressErrors(NotNull<Normalizer> normalizer, TypeId ty);

/**
* Flattens and normalizes the given typepack using the normalizer to determine if the type
* should suppress any errors that would be reported involving it.
* @param normalizer the normalizer to use
* @param tp the typepack to check for error suppression
* @returns an enum indicating whether or not to suppress the error or to signal a normalization failure
*/
ErrorSuppression shouldSuppressErrors(NotNull<Normalizer> normalizer, TypePackId tp);

/**
* Normalizes the two given type using the normalizer to determine if either type
* should suppress any errors that would be reported involving it.
* @param normalizer the normalizer to use
* @param ty1 the first type to check for error suppression
* @param ty2 the second type to check for error suppression
* @returns an enum indicating whether or not to suppress the error or to signal a normalization failure
*/
ErrorSuppression shouldSuppressErrors(NotNull<Normalizer> normalizer, TypeId ty1, TypeId ty2);

/**
* Flattens and normalizes the two given typepacks using the normalizer to determine if either type
* should suppress any errors that would be reported involving it.
* @param normalizer the normalizer to use
* @param tp1 the first typepack to check for error suppression
* @param tp2 the second typepack to check for error suppression
* @returns an enum indicating whether or not to suppress the error or to signal a normalization failure
*/
ErrorSuppression shouldSuppressErrors(NotNull<Normalizer> normalizer, TypePackId tp1, TypePackId tp2);

template<typename T, typename Ty>
const T* get(std::optional<Ty> ty)
{
Expand Down
Loading
Loading