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/650 #1502

Merged
merged 207 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 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
1de169f
Sync to upstream/release/649
aatxe Oct 25, 2024
ed05da5
Merge branch 'master' into merge
aatxe Oct 25, 2024
e85fb91
Merge branch 'upstream' into merge
aatxe Oct 25, 2024
ee5b473
Sync to upstream/release/650
andyfriesen Nov 1, 2024
25de210
Merge branch 'master' into merge
andyfriesen Nov 1, 2024
c6cf1f8
Merge branch 'upstream' into merge
andyfriesen Nov 1, 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
2 changes: 2 additions & 0 deletions Analysis/include/Luau/TypeFunctionRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,6 @@ void registerTypeUserData(lua_State* L);

void setTypeFunctionEnvironment(lua_State* L);

void resetTypeFunctionState(lua_State* L);

} // namespace Luau
4 changes: 2 additions & 2 deletions Analysis/src/AnyTypeSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <stdio.h>

LUAU_FASTFLAGVARIABLE(StudioReportLuauAny2, false);
LUAU_FASTFLAGVARIABLE(StudioReportLuauAny2);
LUAU_FASTINTVARIABLE(LuauAnySummaryRecursionLimit, 300);

LUAU_FASTFLAG(DebugLuauMagicTypes);
Expand Down Expand Up @@ -161,7 +161,7 @@ void AnyTypeSummary::visit(const Scope* scope, AstStatReturn* ret, const Module*
typeInfo.push_back(ti);
}
}

if (ret->list.size > 1 && !seenTP)
{
if (containsAny(retScope->returnType))
Expand Down
2 changes: 1 addition & 1 deletion Analysis/src/AstQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

LUAU_FASTFLAG(LuauSolverV2)

LUAU_FASTFLAGVARIABLE(LuauDocumentationAtPosition, false)
LUAU_FASTFLAGVARIABLE(LuauDocumentationAtPosition)

namespace Luau
{
Expand Down
2 changes: 1 addition & 1 deletion Analysis/src/Autocomplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <utility>

LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAGVARIABLE(AutocompleteRequirePathSuggestions, false)
LUAU_FASTFLAGVARIABLE(AutocompleteRequirePathSuggestions)

LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
LUAU_FASTINT(LuauTypeInferIterationLimit)
Expand Down
95 changes: 64 additions & 31 deletions Analysis/src/BuiltinDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Luau/Ast.h"
#include "Luau/Clone.h"
#include "Luau/DenseHash.h"
#include "Luau/Error.h"
#include "Luau/Frontend.h"
#include "Luau/Symbol.h"
Expand All @@ -29,8 +30,8 @@

LUAU_FASTFLAG(LuauSolverV2)
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
LUAU_FASTFLAGVARIABLE(LuauTypestateBuiltins, false)
LUAU_FASTFLAGVARIABLE(LuauStringFormatArityFix, false)
LUAU_FASTFLAGVARIABLE(LuauTypestateBuiltins2)
LUAU_FASTFLAGVARIABLE(LuauStringFormatArityFix)

LUAU_FASTFLAG(AutocompleteRequirePathSuggestions)

Expand Down Expand Up @@ -421,7 +422,7 @@ void registerBuiltinGlobals(Frontend& frontend, GlobalTypes& globals, bool typeC

attachMagicFunction(ttv->props["pack"].type(), magicFunctionPack);
attachDcrMagicFunction(ttv->props["pack"].type(), dcrMagicFunctionPack);
if (FFlag::LuauTypestateBuiltins)
if (FFlag::LuauTypestateBuiltins2)
attachDcrMagicFunction(ttv->props["freeze"].type(), dcrMagicFunctionFreeze);
}

Expand Down Expand Up @@ -1338,54 +1339,86 @@ static bool dcrMagicFunctionPack(MagicFunctionCallContext context)
return true;
}

static std::optional<TypeId> freezeTable(TypeId inputType, MagicFunctionCallContext& context)
{
TypeArena* arena = context.solver->arena;

if (auto mt = get<MetatableType>(inputType))
{
std::optional<TypeId> frozenTable = freezeTable(mt->table, context);

if (!frozenTable)
return std::nullopt;

TypeId resultType = arena->addType(MetatableType{*frozenTable, mt->metatable, mt->syntheticName});

return resultType;
}

if (get<TableType>(inputType))
{
// Clone the input type, this will become our final result type after we mutate it.
CloneState cloneState{context.solver->builtinTypes};
TypeId resultType = shallowClone(inputType, *arena, cloneState);
auto tableTy = getMutable<TableType>(resultType);
// `clone` should not break this.
LUAU_ASSERT(tableTy);
tableTy->state = TableState::Sealed;

// We'll mutate the table to make every property type read-only.
for (auto iter = tableTy->props.begin(); iter != tableTy->props.end();)
{
if (iter->second.isWriteOnly())
iter = tableTy->props.erase(iter);
else
{
iter->second.writeTy = std::nullopt;
iter++;
}
}

return resultType;
}

context.solver->reportError(TypeMismatch{context.solver->builtinTypes->tableType, inputType}, context.callSite->argLocation);
return std::nullopt;
}

static bool dcrMagicFunctionFreeze(MagicFunctionCallContext context)
{
LUAU_ASSERT(FFlag::LuauTypestateBuiltins);
LUAU_ASSERT(FFlag::LuauTypestateBuiltins2);

TypeArena* arena = context.solver->arena;
const DataFlowGraph* dfg = context.solver->dfg.get();
Scope* scope = context.constraint->scope.get();

const auto& [paramTypes, paramTail] = extendTypePack(*arena, context.solver->builtinTypes, context.arguments, 1);
LUAU_ASSERT(paramTypes.size() >= 1);

TypeId inputType = follow(paramTypes.at(0));

// we'll check if it's a table first since this magic function also produces the error if it's not until we have bounded generics
if (!get<TableType>(inputType))
if (paramTypes.empty() || context.callSite->args.size == 0)
{
context.solver->reportError(TypeMismatch{context.solver->builtinTypes->tableType, inputType}, context.callSite->argLocation);
context.solver->reportError(CountMismatch{1, std::nullopt, 0}, context.callSite->argLocation);
return false;
}

TypeId inputType = follow(paramTypes[0]);

AstExpr* targetExpr = context.callSite->args.data[0];
std::optional<DefId> resultDef = dfg->getDefOptional(targetExpr);
std::optional<TypeId> resultTy = resultDef ? scope->lookup(*resultDef) : std::nullopt;

// Clone the input type, this will become our final result type after we mutate it.
CloneState cloneState{context.solver->builtinTypes};
TypeId clonedType = shallowClone(inputType, *arena, cloneState);
auto tableTy = getMutable<TableType>(clonedType);
// `clone` should not break this.
LUAU_ASSERT(tableTy);
tableTy->state = TableState::Sealed;
tableTy->syntheticName = std::nullopt;

// We'll mutate the table to make every property type read-only.
for (auto iter = tableTy->props.begin(); iter != tableTy->props.end();)
std::optional<TypeId> frozenType = freezeTable(inputType, context);

if (!frozenType)
{
if (iter->second.isWriteOnly())
iter = tableTy->props.erase(iter);
else
{
iter->second.writeTy = std::nullopt;
iter++;
}
if (resultTy)
asMutable(*resultTy)->ty.emplace<BoundType>(context.solver->builtinTypes->errorType);
asMutable(context.result)->ty.emplace<BoundTypePack>(context.solver->builtinTypes->errorTypePack);

return true;
}

if (resultTy)
asMutable(*resultTy)->ty.emplace<BoundType>(clonedType);
asMutable(context.result)->ty.emplace<BoundTypePack>(arena->addTypePack({clonedType}));
asMutable(*resultTy)->ty.emplace<BoundType>(*frozenType);
asMutable(context.result)->ty.emplace<BoundTypePack>(arena->addTypePack({*frozenType}));

return true;
}
Expand Down
12 changes: 6 additions & 6 deletions Analysis/src/ConstraintGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ LUAU_FASTINT(LuauCheckRecursionLimit)
LUAU_FASTFLAG(DebugLuauLogSolverToJson)
LUAU_FASTFLAG(DebugLuauMagicTypes)
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
LUAU_FASTFLAG(LuauTypestateBuiltins)
LUAU_FASTFLAG(LuauTypestateBuiltins2)

LUAU_FASTFLAGVARIABLE(LuauNewSolverVisitErrorExprLvalues, false)
LUAU_FASTFLAGVARIABLE(LuauNewSolverVisitErrorExprLvalues)

namespace Luau
{
Expand Down Expand Up @@ -1078,7 +1078,7 @@ ControlFlow ConstraintGenerator::visit(const ScopePtr& scope, AstStatLocal* stat
addConstraint(scope, value->location, NameConstraint{*firstValueType, var->name.value, /*synthetic*/ true});
else if (const AstExprCall* call = value->as<AstExprCall>())
{
if (FFlag::LuauTypestateBuiltins)
if (FFlag::LuauTypestateBuiltins2)
{
if (matchSetMetatable(*call))
addConstraint(scope, value->location, NameConstraint{*firstValueType, var->name.value, /*synthetic*/ true});
Expand Down Expand Up @@ -2062,7 +2062,7 @@ InferencePack ConstraintGenerator::checkPack(const ScopePtr& scope, AstExprCall*
return InferencePack{arena->addTypePack({resultTy}), {refinementArena.variadic(returnRefinements)}};
}

if (FFlag::LuauTypestateBuiltins && shouldTypestateForFirstArgument(*call) && call->args.size > 0 && isLValue(call->args.data[0]))
if (FFlag::LuauTypestateBuiltins2 && shouldTypestateForFirstArgument(*call) && call->args.size > 0 && isLValue(call->args.data[0]))
{
AstExpr* targetExpr = call->args.data[0];
auto resultTy = arena->addType(BlockedType{});
Expand Down Expand Up @@ -2913,7 +2913,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,
std::vector<TypeId> toBlock;
if (DFInt::LuauTypeSolverRelease >= 648)
{
// This logic is incomplete as we want to re-run this
// This logic is incomplete as we want to re-run this
// _after_ blocked types have resolved, but this
// allows us to do some bidirectional inference.
toBlock = findBlockedTypesIn(expr, NotNull{&module->astTypes});
Expand All @@ -2931,7 +2931,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprTable* expr,
toBlock
);
// The visitor we ran prior should ensure that there are no
// blocked types that we would encounter while matching on
// blocked types that we would encounter while matching on
// this expression.
LUAU_ASSERT(toBlock.empty());
}
Expand Down
10 changes: 5 additions & 5 deletions Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
#include <algorithm>
#include <utility>

LUAU_FASTFLAGVARIABLE(DebugLuauLogSolver, false)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverIncludeDependencies, false)
LUAU_FASTFLAGVARIABLE(DebugLuauLogBindings, false)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolver)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverIncludeDependencies)
LUAU_FASTFLAGVARIABLE(DebugLuauLogBindings)
LUAU_FASTINTVARIABLE(LuauSolverRecursionLimit, 500)
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
LUAU_FASTFLAGVARIABLE(LuauRemoveNotAnyHack, false)
LUAU_FASTFLAGVARIABLE(LuauRemoveNotAnyHack)

namespace Luau
{
Expand Down Expand Up @@ -1337,7 +1337,7 @@ bool ConstraintSolver::tryDispatch(const FunctionCheckConstraint& c, NotNull<con
{
// This is expensive as we need to traverse a (potentially large)
// literal up front in order to determine if there are any blocked
// types, otherwise we may run `matchTypeLiteral` multiple times,
// types, otherwise we may run `matchTypeLiteral` multiple times,
// which right now may fail due to being non-idempotent (it
// destructively updates the underlying literal type).
auto blockedTypes = findBlockedArgTypesIn(c.callSite, c.astTypes);
Expand Down
4 changes: 2 additions & 2 deletions Analysis/src/DataFlowGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

LUAU_FASTFLAG(DebugLuauFreezeArena)
LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAG(LuauTypestateBuiltins)
LUAU_FASTFLAG(LuauTypestateBuiltins2)

namespace Luau
{
Expand Down Expand Up @@ -939,7 +939,7 @@ DataFlowResult DataFlowGraphBuilder::visitExpr(AstExprCall* c)
{
visitExpr(c->func);

if (FFlag::LuauTypestateBuiltins && shouldTypestateForFirstArgument(*c) && c->args.size > 1 && isLValue(*c->args.begin()))
if (FFlag::LuauTypestateBuiltins2 && shouldTypestateForFirstArgument(*c) && c->args.size > 1 && isLValue(*c->args.begin()))
{
AstExpr* firstArg = *c->args.begin();

Expand Down
32 changes: 32 additions & 0 deletions Analysis/src/EmbeddedBuiltinDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

LUAU_FASTFLAG(LuauMathMap)

LUAU_FASTFLAGVARIABLE(LuauVectorDefinitions)

namespace Luau
{

Expand Down Expand Up @@ -450,9 +452,39 @@ declare buffer: {

)BUILTIN_SRC";

static const std::string kBuiltinDefinitionVectorSrc = R"BUILTIN_SRC(

-- TODO: this will be replaced with a built-in primitive type
declare class vector end

declare vector: {
create: @checked (x: number, y: number, z: number) -> vector,
magnitude: @checked (vec: vector) -> number,
normalize: @checked (vec: vector) -> vector,
cross: @checked (vec1: vector, vec2: vector) -> vector,
dot: @checked (vec1: vector, vec2: vector) -> number,
angle: @checked (vec1: vector, vec2: vector, axis: vector?) -> number,
floor: @checked (vec: vector) -> vector,
ceil: @checked (vec: vector) -> vector,
abs: @checked (vec: vector) -> vector,
sign: @checked (vec: vector) -> vector,
clamp: @checked (vec: vector, min: vector, max: vector) -> vector,
max: @checked (vector, ...vector) -> vector,
min: @checked (vector, ...vector) -> vector,

zero: vector,
one: vector,
}

)BUILTIN_SRC";

std::string getBuiltinDefinitionSource()
{
std::string result = FFlag::LuauMathMap ? kBuiltinDefinitionLuaSrcChecked : kBuiltinDefinitionLuaSrcChecked_DEPRECATED;

if (FFlag::LuauVectorDefinitions)
result += kBuiltinDefinitionVectorSrc;

return result;
}

Expand Down
20 changes: 10 additions & 10 deletions Analysis/src/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ LUAU_FASTINT(LuauTypeInferIterationLimit)
LUAU_FASTINT(LuauTypeInferRecursionLimit)
LUAU_FASTINT(LuauTarjanChildLimit)
LUAU_FASTFLAG(LuauInferInNoCheckMode)
LUAU_FASTFLAGVARIABLE(LuauKnowsTheDataModel3, false)
LUAU_FASTFLAGVARIABLE(LuauStoreCommentsForDefinitionFiles, false)
LUAU_FASTFLAGVARIABLE(LuauKnowsTheDataModel3)
LUAU_FASTFLAGVARIABLE(LuauStoreCommentsForDefinitionFiles)
LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJson, false)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJsonFile, false)
LUAU_FASTFLAGVARIABLE(DebugLuauForbidInternalTypes, false)
LUAU_FASTFLAGVARIABLE(DebugLuauForceStrictMode, false)
LUAU_FASTFLAGVARIABLE(DebugLuauForceNonStrictMode, false)
LUAU_FASTFLAGVARIABLE(LuauUserDefinedTypeFunctionNoEvaluation, false)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJson)
LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJsonFile)
LUAU_FASTFLAGVARIABLE(DebugLuauForbidInternalTypes)
LUAU_FASTFLAGVARIABLE(DebugLuauForceStrictMode)
LUAU_FASTFLAGVARIABLE(DebugLuauForceNonStrictMode)
LUAU_FASTFLAGVARIABLE(LuauUserDefinedTypeFunctionNoEvaluation)
LUAU_DYNAMIC_FASTFLAGVARIABLE(LuauRunCustomModuleChecks, false)
LUAU_FASTFLAGVARIABLE(LuauMoreThoroughCycleDetection, false)
LUAU_FASTFLAGVARIABLE(LuauMoreThoroughCycleDetection)

LUAU_FASTFLAG(StudioReportLuauAny2)
LUAU_FASTFLAGVARIABLE(LuauStoreDFGOnModule2, false)
LUAU_FASTFLAGVARIABLE(LuauStoreDFGOnModule2)

namespace Luau
{
Expand Down
2 changes: 1 addition & 1 deletion Analysis/src/Linter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LUAU_FASTFLAG(LuauSolverV2)

LUAU_FASTFLAG(LuauAttribute)
LUAU_FASTFLAG(LuauNativeAttribute)
LUAU_FASTFLAGVARIABLE(LintRedundantNativeAttribute, false)
LUAU_FASTFLAGVARIABLE(LintRedundantNativeAttribute)

namespace Luau
{
Expand Down
6 changes: 5 additions & 1 deletion Analysis/src/NonStrictTypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <iostream>
#include <iterator>

LUAU_FASTFLAGVARIABLE(LuauUserTypeFunNonstrict)

namespace Luau
{

Expand Down Expand Up @@ -421,7 +423,9 @@ struct NonStrictTypeChecker

NonStrictContext visit(AstStatTypeFunction* typeFunc)
{
reportError(GenericError{"This syntax is not supported"}, typeFunc->location);
if (!FFlag::LuauUserTypeFunNonstrict)
reportError(GenericError{"This syntax is not supported"}, typeFunc->location);

return {};
}

Expand Down
Loading
Loading