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/648 #1477

Merged
merged 201 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
201 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
0386eec
Sync to upstream/release/626
vegorov-rbx May 16, 2024
e5de2ed
Merge branch 'master' into merge
vegorov-rbx May 16, 2024
ca46dd6
Merge branch 'upstream' into merge
vegorov-rbx May 16, 2024
0f61e4e
Merge fix
vegorov-rbx May 16, 2024
bad9e14
627
aatxe May 26, 2024
26fb155
Merge branch 'master' into merge
aatxe May 26, 2024
241fcf8
Merge branch 'upstream' into merge
aatxe May 26, 2024
fede4d6
Sync to upstream/release/628
alexmccord May 31, 2024
09e46d1
Merge branch 'master' into merge
alexmccord May 31, 2024
93a89dc
Merge branch 'heads/upstream' into merge
alexmccord May 31, 2024
5dd9735
Sync to upstream/release/629
andyfriesen Jun 7, 2024
eae092a
Merge branch 'master' into merge
andyfriesen Jun 7, 2024
40e0316
Merge branch 'upstream' into merge
andyfriesen Jun 7, 2024
58b9809
Sync to upstream/release/630
Vighnesh-V Jun 14, 2024
91790ef
Merge branch 'master' into merge
Vighnesh-V Jun 14, 2024
2a1359d
Merge branch 'upstream' into merge
Vighnesh-V Jun 14, 2024
1ba3e5f
correct the flag name
Vighnesh-V Jun 14, 2024
816cb1d
Sync to upstream/release/631
vegorov-rbx Jun 20, 2024
5d2e3de
Merge branch 'master' into merge
vegorov-rbx Jun 20, 2024
dafb44d
Merge branch 'upstream' into merge
vegorov-rbx Jun 20, 2024
240a9d8
Sync to upstream/release/632
aatxe Jun 29, 2024
c5a2a4b
Merge branch 'master' into merge
aatxe Jun 29, 2024
da48758
Merge branch 'upstream' into merge
aatxe Jun 29, 2024
cfcb545
Sync to upstream/release/633
Vighnesh-V Jul 8, 2024
2010be1
Merge branch 'master' into merge
Vighnesh-V Jul 8, 2024
bc1bead
Merge branch 'upstream' into merge
Vighnesh-V Jul 8, 2024
1c1476f
Sync to upstream/release/634
joonyoo181 Jul 11, 2024
a62f661
Merge branch 'master' into merge
joonyoo181 Jul 11, 2024
5a23350
Merge branch 'upstream' into merge
joonyoo181 Jul 11, 2024
6fd26c5
Sync to upstream/release/635
Vighnesh-V Jul 19, 2024
79966e9
Merge branch 'master' into merge
Vighnesh-V Jul 19, 2024
ac97a49
Merge branch 'upstream' into merge
Vighnesh-V Jul 19, 2024
7dd10b1
Sync to upstream/release/636
joonyoo181 Jul 26, 2024
fab4eec
Merge branch 'master' into merge
joonyoo181 Jul 26, 2024
48c0e9f
Merge branch 'upstream' into merge
joonyoo181 Jul 26, 2024
bb7d5cf
StudioReportLuauAny added to ExperimentalFlags
joonyoo181 Jul 26, 2024
28c48cf
Skip StudioReportLuauAny flag in tests
joonyoo181 Jul 26, 2024
fad8aaf
Sync to upstream/release/637
joonyoo181 Aug 1, 2024
5b40152
Merge branch 'master' into merge
joonyoo181 Aug 1, 2024
1adbd45
Merge branch 'upstream' into merge
joonyoo181 Aug 1, 2024
8a99f25
Sync to upstream/release/638
andyfriesen Aug 9, 2024
057bdf3
Merge branch 'master' into merge
andyfriesen Aug 9, 2024
c229a9e
Merge branch 'upstream' into merge
andyfriesen Aug 9, 2024
497c3ed
Sync to upstream/release/639
Vighnesh-V Aug 16, 2024
8c4f907
Merge branch 'master' into merge
Vighnesh-V Aug 16, 2024
3613ee9
Merge branch 'upstream' into merge
Vighnesh-V Aug 16, 2024
ebdbcb1
Sync to upstream/release/640
vegorov-rbx Aug 23, 2024
caeba5a
Merge branch 'master' into merge
vegorov-rbx Aug 23, 2024
d414b56
Merge branch 'upstream' into merge
vegorov-rbx Aug 23, 2024
5b9344a
Missing sync elements
vegorov-rbx Aug 23, 2024
25db8ff
Success, DCR mode no longer fails any tests
vegorov-rbx Aug 23, 2024
a74031b
Sync release to upstream/release/641
aatxe Aug 30, 2024
78ae885
Merge branch 'master' into merge
aatxe Aug 30, 2024
f86f0a4
Merge branch 'upstream' into merge
aatxe Aug 30, 2024
15557d8
Sync to upstream/release/642
andyfriesen Sep 6, 2024
538b0c0
Merge branch 'master' into merge
andyfriesen Sep 6, 2024
ef8e1e3
Merge branch 'upstream' into merge
andyfriesen Sep 6, 2024
cd27a20
Sync to upstream/release/643
Vighnesh-V Sep 13, 2024
23e9fa5
Merge branch 'master' into merge
Vighnesh-V Sep 13, 2024
4df4a1d
Merge branch 'upstream' into merge
Vighnesh-V Sep 13, 2024
a45eb2c
Sync to upstream/release/644
vegorov-rbx Sep 20, 2024
d66e088
Merge branch 'master' into merge
vegorov-rbx Sep 20, 2024
0d6b70b
Merge branch 'upstream' into merge
vegorov-rbx Sep 20, 2024
66ba360
Smaller limit under ASAN for autocomplete_subtyping_recursion_limit
vegorov-rbx Sep 20, 2024
9655780
Reduce it even more
vegorov-rbx Sep 20, 2024
0106dfa
Maybe reduce the base
vegorov-rbx Sep 20, 2024
48f3c85
Maybe more?
vegorov-rbx Sep 20, 2024
45594a5
Fixed the issue
vegorov-rbx Sep 20, 2024
7a7521a
Sync to upstream/release/645
aatxe Sep 27, 2024
e888049
Merge branch 'master' into merge
aatxe Sep 27, 2024
a3da985
Merge branch 'upstream' into merge
aatxe Sep 27, 2024
d7bbe3f
fix cmake for user-defined type functions
aatxe Sep 27, 2024
8531df0
Sync to upstream/release/646
andyfriesen Oct 4, 2024
469ba77
Merge branch 'master' into merge
andyfriesen Oct 4, 2024
aabaf01
Merge branch 'upstream' into merge
andyfriesen Oct 4, 2024
aa2e5c0
Sync to upstream/release/647
Vighnesh-V Oct 11, 2024
40a054a
Merge branch 'master' into merge
Vighnesh-V Oct 11, 2024
912798e
Merge branch 'upstream' into merge
Vighnesh-V Oct 11, 2024
afa4fa6
try to disable self-move warning
Vighnesh-V Oct 11, 2024
0e1504f
try a different syntax for disabling warnings
Vighnesh-V Oct 11, 2024
38d76e6
disable maybe uninitialized error
Vighnesh-V Oct 11, 2024
5bb24aa
nit: turn int osize, nsize into size_t
Vighnesh-V Oct 11, 2024
a02bee5
update -Wmaybe-uninitialized
Vighnesh-V Oct 11, 2024
f52fe9f
nit - remove shared code allocator test section that tests self move
Vighnesh-V Oct 11, 2024
69776f6
re-add assertion
Vighnesh-V Oct 11, 2024
ee6a45b
more macro madness
Vighnesh-V Oct 11, 2024
74c1ac3
nit - insert new lines
Vighnesh-V Oct 11, 2024
70d5a0e
newline
Vighnesh-V Oct 11, 2024
34801b9
Delete tests/.#TypeVar.test.cpp
Vighnesh-V Oct 11, 2024
39899ad
macro out the failing tests
Vighnesh-V Oct 11, 2024
ef95ce5
newline
Vighnesh-V Oct 11, 2024
a197f04
i messed up the macro syntax again
Vighnesh-V Oct 11, 2024
68b9214
push same change to shared code allocator
Vighnesh-V Oct 11, 2024
507832b
default initialize
Vighnesh-V Oct 11, 2024
b76941b
annotate this optional use
Vighnesh-V Oct 11, 2024
848fa0b
insert new lines
Vighnesh-V Oct 11, 2024
c9ff5d1
nest pragma
Vighnesh-V Oct 11, 2024
dafee8b
nest again
Vighnesh-V Oct 11, 2024
50e8dd0
more macro crimes
Vighnesh-V Oct 11, 2024
b1fae55
nit differ
Vighnesh-V Oct 11, 2024
0276d18
one more try
Vighnesh-V Oct 11, 2024
b5d3544
update build flags
Vighnesh-V Oct 11, 2024
03c9fa7
try again?
Vighnesh-V Oct 11, 2024
a7324ce
what happens if we remove the flag
Vighnesh-V Oct 11, 2024
5d74685
unconditially add suppressing flag
Vighnesh-V Oct 11, 2024
837bba3
revert cmake file + update makefile
Vighnesh-V Oct 11, 2024
268e0b2
revert differ.h change
Vighnesh-V Oct 12, 2024
fb8c190
replicate changes to cmakelists
Vighnesh-V Oct 12, 2024
47e3123
Sync to upstream/release/648
vegorov-rbx Oct 18, 2024
bbd18bf
Merge branch 'master' into merge
vegorov-rbx Oct 18, 2024
ce9f1eb
Merge branch 'upstream' into merge
vegorov-rbx Oct 18, 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
1 change: 1 addition & 0 deletions Analysis/include/Luau/Autocomplete.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum class AutocompleteEntryKind
Type,
Module,
GeneratedFunction,
RequirePath,
};

enum class ParenthesesRecommendation
Expand Down
2 changes: 2 additions & 0 deletions Analysis/include/Luau/BuiltinDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace Luau
{

static constexpr char kRequireTagName[] = "require";

struct Frontend;
struct GlobalTypes;
struct TypeChecker;
Expand Down
183 changes: 111 additions & 72 deletions Analysis/include/Luau/DataFlowGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ struct DataFlowGraph
DenseHashMap<const AstExpr*, const Def*> compoundAssignDefs{nullptr};

DenseHashMap<const AstExpr*, const RefinementKey*> astRefinementKeys{nullptr};

friend struct DataFlowGraphBuilder;
};

Expand All @@ -83,6 +82,7 @@ struct DfgScope

DfgScope* parent;
ScopeType scopeType;
Location location;

using Bindings = DenseHashMap<Symbol, const Def*>;
using Props = DenseHashMap<const Def*, std::unordered_map<std::string, const Def*>>;
Expand All @@ -105,10 +105,44 @@ struct DataFlowResult
const RefinementKey* parent = nullptr;
};

using ScopeStack = std::vector<DfgScope*>;

struct DataFlowGraphBuilder
{
static DataFlowGraph build(AstStatBlock* root, NotNull<struct InternalErrorReporter> handle);

/**
* This method is identical to the build method above, but returns a pair of dfg, scopes as the data flow graph
* here is intended to live on the module between runs of typechecking. Before, the DFG only needed to live as
* long as the typecheck, but in a world with incremental typechecking, we need the information on the dfg to incrementally
* typecheck small fragments of code.
* @param block - pointer to the ast to build the dfg for
* @param handle - for raising internal errors while building the dfg
*/
static std::pair<std::shared_ptr<DataFlowGraph>, std::vector<std::unique_ptr<DfgScope>>> buildShared(
AstStatBlock* block,
NotNull<InternalErrorReporter> handle
);

/**
* Takes a stale graph along with a list of scopes, a small fragment of the ast, and a cursor position
* and constructs the DataFlowGraph for just that fragment. This method will fabricate defs in the final
* DFG for things that have been referenced and exist in the stale dfg.
* For example, the fragment local z = x + y will populate defs for x and y from the stale graph.
* @param staleGraph - the old DFG
* @param scopes - the old DfgScopes in the graph
* @param fragment - the Ast Fragment to re-build the root for
* @param cursorPos - the current location of the cursor - used to determine which scope we are currently in
* @param handle - for internal compiler errors
*/
static DataFlowGraph updateGraph(
const DataFlowGraph& staleGraph,
const std::vector<std::unique_ptr<DfgScope>>& scopes,
AstStatBlock* fragment,
const Position& cursorPos,
NotNull<InternalErrorReporter> handle
);

private:
DataFlowGraphBuilder() = default;

Expand All @@ -120,10 +154,15 @@ struct DataFlowGraphBuilder
NotNull<RefinementKeyArena> keyArena{&graph.keyArena};

struct InternalErrorReporter* handle = nullptr;
DfgScope* moduleScope = nullptr;

/// The arena owning all of the scope allocations for the dataflow graph being built.
std::vector<std::unique_ptr<DfgScope>> scopes;

/// A stack of scopes used by the visitor to see where we are.
ScopeStack scopeStack;

DfgScope* currentScope();

struct FunctionCapture
{
std::vector<DefId> captureDefs;
Expand All @@ -134,81 +173,81 @@ struct DataFlowGraphBuilder
DenseHashMap<Symbol, FunctionCapture> captures{Symbol{}};
void resolveCaptures();

DfgScope* childScope(DfgScope* scope, DfgScope::ScopeType scopeType = DfgScope::Linear);
DfgScope* makeChildScope(Location loc, DfgScope::ScopeType scopeType = DfgScope::Linear);

void join(DfgScope* p, DfgScope* a, DfgScope* b);
void joinBindings(DfgScope* p, const DfgScope& a, const DfgScope& b);
void joinProps(DfgScope* p, const DfgScope& a, const DfgScope& b);

DefId lookup(DfgScope* scope, Symbol symbol);
DefId lookup(DfgScope* scope, DefId def, const std::string& key);

ControlFlow visit(DfgScope* scope, AstStatBlock* b);
ControlFlow visitBlockWithoutChildScope(DfgScope* scope, AstStatBlock* b);

ControlFlow visit(DfgScope* scope, AstStat* s);
ControlFlow visit(DfgScope* scope, AstStatIf* i);
ControlFlow visit(DfgScope* scope, AstStatWhile* w);
ControlFlow visit(DfgScope* scope, AstStatRepeat* r);
ControlFlow visit(DfgScope* scope, AstStatBreak* b);
ControlFlow visit(DfgScope* scope, AstStatContinue* c);
ControlFlow visit(DfgScope* scope, AstStatReturn* r);
ControlFlow visit(DfgScope* scope, AstStatExpr* e);
ControlFlow visit(DfgScope* scope, AstStatLocal* l);
ControlFlow visit(DfgScope* scope, AstStatFor* f);
ControlFlow visit(DfgScope* scope, AstStatForIn* f);
ControlFlow visit(DfgScope* scope, AstStatAssign* a);
ControlFlow visit(DfgScope* scope, AstStatCompoundAssign* c);
ControlFlow visit(DfgScope* scope, AstStatFunction* f);
ControlFlow visit(DfgScope* scope, AstStatLocalFunction* l);
ControlFlow visit(DfgScope* scope, AstStatTypeAlias* t);
ControlFlow visit(DfgScope* scope, AstStatTypeFunction* f);
ControlFlow visit(DfgScope* scope, AstStatDeclareGlobal* d);
ControlFlow visit(DfgScope* scope, AstStatDeclareFunction* d);
ControlFlow visit(DfgScope* scope, AstStatDeclareClass* d);
ControlFlow visit(DfgScope* scope, AstStatError* error);

DataFlowResult visitExpr(DfgScope* scope, AstExpr* e);
DataFlowResult visitExpr(DfgScope* scope, AstExprGroup* group);
DataFlowResult visitExpr(DfgScope* scope, AstExprLocal* l);
DataFlowResult visitExpr(DfgScope* scope, AstExprGlobal* g);
DataFlowResult visitExpr(DfgScope* scope, AstExprCall* c);
DataFlowResult visitExpr(DfgScope* scope, AstExprIndexName* i);
DataFlowResult visitExpr(DfgScope* scope, AstExprIndexExpr* i);
DataFlowResult visitExpr(DfgScope* scope, AstExprFunction* f);
DataFlowResult visitExpr(DfgScope* scope, AstExprTable* t);
DataFlowResult visitExpr(DfgScope* scope, AstExprUnary* u);
DataFlowResult visitExpr(DfgScope* scope, AstExprBinary* b);
DataFlowResult visitExpr(DfgScope* scope, AstExprTypeAssertion* t);
DataFlowResult visitExpr(DfgScope* scope, AstExprIfElse* i);
DataFlowResult visitExpr(DfgScope* scope, AstExprInterpString* i);
DataFlowResult visitExpr(DfgScope* scope, AstExprError* error);

void visitLValue(DfgScope* scope, AstExpr* e, DefId incomingDef);
DefId visitLValue(DfgScope* scope, AstExprLocal* l, DefId incomingDef);
DefId visitLValue(DfgScope* scope, AstExprGlobal* g, DefId incomingDef);
DefId visitLValue(DfgScope* scope, AstExprIndexName* i, DefId incomingDef);
DefId visitLValue(DfgScope* scope, AstExprIndexExpr* i, DefId incomingDef);
DefId visitLValue(DfgScope* scope, AstExprError* e, DefId incomingDef);

void visitType(DfgScope* scope, AstType* t);
void visitType(DfgScope* scope, AstTypeReference* r);
void visitType(DfgScope* scope, AstTypeTable* t);
void visitType(DfgScope* scope, AstTypeFunction* f);
void visitType(DfgScope* scope, AstTypeTypeof* t);
void visitType(DfgScope* scope, AstTypeUnion* u);
void visitType(DfgScope* scope, AstTypeIntersection* i);
void visitType(DfgScope* scope, AstTypeError* error);

void visitTypePack(DfgScope* scope, AstTypePack* p);
void visitTypePack(DfgScope* scope, AstTypePackExplicit* e);
void visitTypePack(DfgScope* scope, AstTypePackVariadic* v);
void visitTypePack(DfgScope* scope, AstTypePackGeneric* g);

void visitTypeList(DfgScope* scope, AstTypeList l);

void visitGenerics(DfgScope* scope, AstArray<AstGenericType> g);
void visitGenericPacks(DfgScope* scope, AstArray<AstGenericTypePack> g);
DefId lookup(Symbol symbol);
DefId lookup(DefId def, const std::string& key);

ControlFlow visit(AstStatBlock* b);
ControlFlow visitBlockWithoutChildScope(AstStatBlock* b);

ControlFlow visit(AstStat* s);
ControlFlow visit(AstStatIf* i);
ControlFlow visit(AstStatWhile* w);
ControlFlow visit(AstStatRepeat* r);
ControlFlow visit(AstStatBreak* b);
ControlFlow visit(AstStatContinue* c);
ControlFlow visit(AstStatReturn* r);
ControlFlow visit(AstStatExpr* e);
ControlFlow visit(AstStatLocal* l);
ControlFlow visit(AstStatFor* f);
ControlFlow visit(AstStatForIn* f);
ControlFlow visit(AstStatAssign* a);
ControlFlow visit(AstStatCompoundAssign* c);
ControlFlow visit(AstStatFunction* f);
ControlFlow visit(AstStatLocalFunction* l);
ControlFlow visit(AstStatTypeAlias* t);
ControlFlow visit(AstStatTypeFunction* f);
ControlFlow visit(AstStatDeclareGlobal* d);
ControlFlow visit(AstStatDeclareFunction* d);
ControlFlow visit(AstStatDeclareClass* d);
ControlFlow visit(AstStatError* error);

DataFlowResult visitExpr(AstExpr* e);
DataFlowResult visitExpr(AstExprGroup* group);
DataFlowResult visitExpr(AstExprLocal* l);
DataFlowResult visitExpr(AstExprGlobal* g);
DataFlowResult visitExpr(AstExprCall* c);
DataFlowResult visitExpr(AstExprIndexName* i);
DataFlowResult visitExpr(AstExprIndexExpr* i);
DataFlowResult visitExpr(AstExprFunction* f);
DataFlowResult visitExpr(AstExprTable* t);
DataFlowResult visitExpr(AstExprUnary* u);
DataFlowResult visitExpr(AstExprBinary* b);
DataFlowResult visitExpr(AstExprTypeAssertion* t);
DataFlowResult visitExpr(AstExprIfElse* i);
DataFlowResult visitExpr(AstExprInterpString* i);
DataFlowResult visitExpr(AstExprError* error);

void visitLValue(AstExpr* e, DefId incomingDef);
DefId visitLValue(AstExprLocal* l, DefId incomingDef);
DefId visitLValue(AstExprGlobal* g, DefId incomingDef);
DefId visitLValue(AstExprIndexName* i, DefId incomingDef);
DefId visitLValue(AstExprIndexExpr* i, DefId incomingDef);
DefId visitLValue(AstExprError* e, DefId incomingDef);

void visitType(AstType* t);
void visitType(AstTypeReference* r);
void visitType(AstTypeTable* t);
void visitType(AstTypeFunction* f);
void visitType(AstTypeTypeof* t);
void visitType(AstTypeUnion* u);
void visitType(AstTypeIntersection* i);
void visitType(AstTypeError* error);

void visitTypePack(AstTypePack* p);
void visitTypePack(AstTypePackExplicit* e);
void visitTypePack(AstTypePackVariadic* v);
void visitTypePack(AstTypePackGeneric* g);

void visitTypeList(AstTypeList l);

void visitGenerics(AstArray<AstGenericType> g);
void visitGenericPacks(AstArray<AstGenericTypePack> g);
};

} // namespace Luau
9 changes: 9 additions & 0 deletions Analysis/include/Luau/FileResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <string>
#include <optional>
#include <vector>

namespace Luau
{
Expand Down Expand Up @@ -31,6 +32,9 @@ struct ModuleInfo
bool optional = false;
};

using RequireSuggestion = std::string;
using RequireSuggestions = std::vector<RequireSuggestion>;

struct FileResolver
{
virtual ~FileResolver() {}
Expand All @@ -51,6 +55,11 @@ struct FileResolver
{
return std::nullopt;
}

virtual std::optional<RequireSuggestions> getRequireSuggestions(const ModuleName& requirer, const std::optional<std::string>& pathString) const
{
return std::nullopt;
}
};

struct NullFileResolver : FileResolver
Expand Down
28 changes: 25 additions & 3 deletions Analysis/include/Luau/FragmentAutocomplete.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// 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/Ast.h"
#include "Luau/Parser.h"
#include "Luau/Autocomplete.h"
#include "Luau/DenseHash.h"
#include "Luau/Module.h"

#include <memory>
#include <vector>


namespace Luau
{

Expand All @@ -15,9 +18,28 @@ struct FragmentAutocompleteAncestryResult
DenseHashMap<AstName, AstLocal*> localMap{AstName()};
std::vector<AstLocal*> localStack;
std::vector<AstNode*> ancestry;
AstStat* nearestStatement;
AstStat* nearestStatement = nullptr;
};

struct FragmentParseResult
{
std::string fragmentToParse;
AstStatBlock* root = nullptr;
std::vector<AstNode*> ancestry;
std::unique_ptr<Allocator> alloc = std::make_unique<Allocator>();
};

FragmentAutocompleteAncestryResult findAncestryForFragmentParse(AstStatBlock* root, const Position& cursorPos);

FragmentParseResult parseFragment(const SourceModule& srcModule, std::string_view src, const Position& cursorPos);

AutocompleteResult fragmentAutocomplete(
Frontend& frontend,
std::string_view src,
const ModuleName& moduleName,
Position& cursorPosition,
StringCompletionCallback callback
);


} // namespace Luau
4 changes: 4 additions & 0 deletions Analysis/include/Luau/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Luau/Scope.h"
#include "Luau/TypeArena.h"
#include "Luau/AnyTypeSummary.h"
#include "Luau/DataFlowGraph.h"

#include <memory>
#include <vector>
Expand Down Expand Up @@ -131,6 +132,9 @@ struct Module

TypePackId returnType = nullptr;
std::unordered_map<Name, TypeFun> exportedTypeBindings;
// We also need to keep DFG data alive between runs
std::shared_ptr<DataFlowGraph> dataFlowGraph = nullptr;
std::vector<std::unique_ptr<DfgScope>> dfgScopes;

bool hasModuleScope() const;
ScopePtr getModuleScope() const;
Expand Down
7 changes: 7 additions & 0 deletions Analysis/include/Luau/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@ struct AnyType
{
};

// A special, trivial type for the refinement system that is always eliminated from intersections.
struct NoRefineType
{
};

// `T | U`
struct UnionType
{
Expand Down Expand Up @@ -755,6 +760,7 @@ using TypeVariant = Unifiable::Variant<
UnknownType,
NeverType,
NegationType,
NoRefineType,
TypeFunctionInstanceType>;

struct Type final
Expand Down Expand Up @@ -949,6 +955,7 @@ struct BuiltinTypes
const TypeId unknownType;
const TypeId neverType;
const TypeId errorType;
const TypeId noRefineType;
const TypeId falsyType;
const TypeId truthyType;

Expand Down
Loading
Loading