@@ -18,9 +18,6 @@ LUAU_FASTINTVARIABLE(LuauParseErrorLimit, 100)
18
18
// flag so that we don't break production games by reverting syntax changes.
19
19
// See docs/SyntaxChanges.md for an explanation.
20
20
LUAU_FASTFLAGVARIABLE(LuauSolverV2)
21
- LUAU_FASTFLAGVARIABLE(LuauAllowComplexTypesInGenericParams)
22
- LUAU_FASTFLAGVARIABLE(LuauErrorRecoveryForTableTypes)
23
- LUAU_FASTFLAGVARIABLE(LuauExtendStatEndPosWithSemicolon)
24
21
LUAU_FASTFLAGVARIABLE(LuauStoreCSTData2)
25
22
LUAU_FASTFLAGVARIABLE(LuauPreserveUnionIntersectionNodeForLeadingTokenSingleType)
26
23
LUAU_FASTFLAGVARIABLE(LuauAstTypeGroup3)
@@ -204,7 +201,9 @@ ParseExprResult Parser::parseExpr(const char* buffer, size_t bufferSize, AstName
204
201
AstExpr* expr = p.parseExpr ();
205
202
size_t lines = p.lexer .current ().location .end .line + (bufferSize > 0 && buffer[bufferSize - 1 ] != ' \n ' );
206
203
207
- return ParseExprResult{expr, lines, std::move (p.hotcomments ), std::move (p.parseErrors ), std::move (p.commentLocations ), std::move (p.cstNodeMap )};
204
+ return ParseExprResult{
205
+ expr, lines, std::move (p.hotcomments ), std::move (p.parseErrors ), std::move (p.commentLocations ), std::move (p.cstNodeMap )
206
+ };
208
207
}
209
208
catch (ParseError& err)
210
209
{
@@ -316,10 +315,7 @@ AstStatBlock* Parser::parseBlockNoScope()
316
315
{
317
316
nextLexeme ();
318
317
stat->hasSemicolon = true ;
319
- if (FFlag::LuauExtendStatEndPosWithSemicolon)
320
- {
321
- stat->location .end = lexer.previousLocation ().end ;
322
- }
318
+ stat->location .end = lexer.previousLocation ().end ;
323
319
}
324
320
325
321
body.push_back (stat);
@@ -745,14 +741,7 @@ AstExpr* Parser::parseFunctionName(bool& hasself, AstName& debugname)
745
741
// while we could concatenate the name chain, for now let's just write the short name
746
742
debugname = name.name ;
747
743
748
- expr = allocator.alloc <AstExprIndexName>(
749
- Location (expr->location , name.location ),
750
- expr,
751
- name.name ,
752
- name.location ,
753
- opPosition,
754
- ' .'
755
- );
744
+ expr = allocator.alloc <AstExprIndexName>(Location (expr->location , name.location ), expr, name.name , name.location , opPosition, ' .' );
756
745
757
746
// note: while the parser isn't recursive here, we're generating recursive structures of unbounded depth
758
747
incrementRecursionCounter (" function name" );
@@ -771,14 +760,7 @@ AstExpr* Parser::parseFunctionName(bool& hasself, AstName& debugname)
771
760
// while we could concatenate the name chain, for now let's just write the short name
772
761
debugname = name.name ;
773
762
774
- expr = allocator.alloc <AstExprIndexName>(
775
- Location (expr->location , name.location ),
776
- expr,
777
- name.name ,
778
- name.location ,
779
- opPosition,
780
- ' :'
781
- );
763
+ expr = allocator.alloc <AstExprIndexName>(Location (expr->location , name.location ), expr, name.name , name.location , opPosition, ' :' );
782
764
783
765
hasself = true ;
784
766
}
@@ -1666,13 +1648,12 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
1666
1648
1667
1649
auto * cstNode = FFlag::LuauStoreCSTData2 && options.storeCstData ? allocator.alloc <CstExprFunction>() : nullptr ;
1668
1650
1669
- auto [generics, genericPacks] = FFlag::LuauStoreCSTData2 && cstNode ? parseGenericTypeList (
1670
- /* withDefaultValues= */ false ,
1671
- &cstNode->openGenericsPosition ,
1672
- &cstNode->genericsCommaPositions ,
1673
- &cstNode->closeGenericsPosition
1674
- )
1675
- : parseGenericTypeList (/* withDefaultValues= */ false );
1651
+ auto [generics, genericPacks] =
1652
+ FFlag::LuauStoreCSTData2 && cstNode
1653
+ ? parseGenericTypeList (
1654
+ /* withDefaultValues= */ false , &cstNode->openGenericsPosition , &cstNode->genericsCommaPositions , &cstNode->closeGenericsPosition
1655
+ )
1656
+ : parseGenericTypeList (/* withDefaultValues= */ false );
1676
1657
1677
1658
MatchLexeme matchParen = lexer.current ();
1678
1659
expectAndConsume (' (' , " function" );
@@ -1687,8 +1668,7 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
1687
1668
//
1688
1669
// function (t: { a: number }) end
1689
1670
//
1690
- if (FFlag::LuauErrorRecoveryForTableTypes)
1691
- matchRecoveryStopOnToken[' )' ]++;
1671
+ matchRecoveryStopOnToken[' )' ]++;
1692
1672
1693
1673
TempVector<Binding> args (scratchBinding);
1694
1674
@@ -1707,8 +1687,7 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
1707
1687
1708
1688
expectMatchAndConsume (' )' , matchParen, true );
1709
1689
1710
- if (FFlag::LuauErrorRecoveryForTableTypes)
1711
- matchRecoveryStopOnToken[' )' ]--;
1690
+ matchRecoveryStopOnToken[' )' ]--;
1712
1691
1713
1692
std::optional<AstTypeList> typelist = parseOptionalReturnType (cstNode ? &cstNode->returnSpecifierPosition : nullptr );
1714
1693
@@ -1822,7 +1801,12 @@ Parser::Binding Parser::parseBinding()
1822
1801
}
1823
1802
1824
1803
// bindinglist ::= (binding | `...') [`,' bindinglist]
1825
- std::tuple<bool , Location, AstTypePack*> Parser::parseBindingList (TempVector<Binding>& result, bool allowDot3, AstArray<Position>* commaPositions, std::optional<Position> initialCommaPosition)
1804
+ std::tuple<bool , Location, AstTypePack*> Parser::parseBindingList (
1805
+ TempVector<Binding>& result,
1806
+ bool allowDot3,
1807
+ AstArray<Position>* commaPositions,
1808
+ std::optional<Position> initialCommaPosition
1809
+ )
1826
1810
{
1827
1811
TempVector<Position> localCommaPositions (scratchPosition);
1828
1812
@@ -2185,6 +2169,7 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
2185
2169
if (FFlag::LuauStoreCSTData2 && options.storeCstData )
2186
2170
std::tie (style, blockDepth) = extractStringDetails ();
2187
2171
2172
+ Position stringPosition = lexer.current ().location .begin ;
2188
2173
AstArray<char > sourceString;
2189
2174
std::optional<AstArray<char >> chars = parseCharArray (options.storeCstData ? &sourceString : nullptr );
2190
2175
@@ -2209,7 +2194,8 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
2209
2194
colonPosition,
2210
2195
tableSeparator (),
2211
2196
lexer.current ().location .begin ,
2212
- allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth)
2197
+ allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth),
2198
+ stringPosition
2213
2199
});
2214
2200
}
2215
2201
else
@@ -2300,6 +2286,7 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
2300
2286
if (FFlag::LuauStoreCSTData2 && options.storeCstData )
2301
2287
std::tie (style, blockDepth) = extractStringDetails ();
2302
2288
2289
+ Position stringPosition = lexer.current ().location .begin ;
2303
2290
AstArray<char > sourceString;
2304
2291
std::optional<AstArray<char >> chars = parseCharArray (options.storeCstData ? &sourceString : nullptr );
2305
2292
@@ -2324,7 +2311,8 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
2324
2311
colonPosition,
2325
2312
tableSeparator (),
2326
2313
lexer.current ().location .begin ,
2327
- allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth)
2314
+ allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth),
2315
+ stringPosition
2328
2316
});
2329
2317
}
2330
2318
else
@@ -2420,7 +2408,7 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
2420
2408
2421
2409
Location end = lexer.current ().location ;
2422
2410
2423
- if (!expectMatchAndConsume (' }' , matchBrace, /* searchForMissing = */ FFlag::LuauErrorRecoveryForTableTypes ))
2411
+ if (!expectMatchAndConsume (' }' , matchBrace, /* searchForMissing = */ true ))
2424
2412
end = lexer.previousLocation ();
2425
2413
2426
2414
if (FFlag::LuauStoreCSTData2)
@@ -4100,78 +4088,66 @@ AstArray<AstTypeOrPack> Parser::parseTypeParams(Position* openingPosition, TempV
4100
4088
}
4101
4089
else if (lexer.current ().type == ' (' )
4102
4090
{
4103
- if (FFlag::LuauAllowComplexTypesInGenericParams)
4104
- {
4105
- Location begin = lexer.current ().location ;
4106
- AstType* type = nullptr ;
4107
- AstTypePack* typePack = nullptr ;
4108
- Lexeme::Type c = lexer.current ().type ;
4091
+ Location begin = lexer.current ().location ;
4092
+ AstType* type = nullptr ;
4093
+ AstTypePack* typePack = nullptr ;
4094
+ Lexeme::Type c = lexer.current ().type ;
4109
4095
4110
- if (c != ' |' && c != ' &' )
4111
- {
4112
- auto typeOrTypePack = parseSimpleType (/* allowPack */ true , /* inDeclarationContext */ false );
4113
- type = typeOrTypePack.type ;
4114
- typePack = typeOrTypePack.typePack ;
4115
- }
4096
+ if (c != ' |' && c != ' &' )
4097
+ {
4098
+ auto typeOrTypePack = parseSimpleType (/* allowPack */ true , /* inDeclarationContext */ false );
4099
+ type = typeOrTypePack.type ;
4100
+ typePack = typeOrTypePack.typePack ;
4101
+ }
4116
4102
4117
- // Consider the following type:
4118
- //
4119
- // X<(T)>
4120
- //
4121
- // Is this a type pack or a parenthesized type? The
4122
- // assumption will be a type pack, as that's what allows one
4123
- // to express either a singular type pack or a potential
4124
- // complex type.
4103
+ // Consider the following type:
4104
+ //
4105
+ // X<(T)>
4106
+ //
4107
+ // Is this a type pack or a parenthesized type? The
4108
+ // assumption will be a type pack, as that's what allows one
4109
+ // to express either a singular type pack or a potential
4110
+ // complex type.
4125
4111
4126
- if (typePack)
4112
+ if (typePack)
4113
+ {
4114
+ auto explicitTypePack = typePack->as <AstTypePackExplicit>();
4115
+ if (explicitTypePack && explicitTypePack->typeList .tailType == nullptr && explicitTypePack->typeList .types .size == 1 &&
4116
+ isTypeFollow (lexer.current ().type ))
4127
4117
{
4128
- auto explicitTypePack = typePack->as <AstTypePackExplicit>();
4129
- if (explicitTypePack && explicitTypePack->typeList .tailType == nullptr && explicitTypePack->typeList .types .size == 1 &&
4130
- isTypeFollow (lexer.current ().type ))
4118
+ // If we parsed an explicit type pack with a single
4119
+ // type in it (something of the form `(T)`), and
4120
+ // the next lexeme is one that follows a type
4121
+ // (&, |, ?), then assume that this was actually a
4122
+ // parenthesized type.
4123
+ if (FFlag::LuauAstTypeGroup3)
4131
4124
{
4132
- // If we parsed an explicit type pack with a single
4133
- // type in it (something of the form `(T)`), and
4134
- // the next lexeme is one that follows a type
4135
- // (&, |, ?), then assume that this was actually a
4136
- // parenthesized type.
4137
- if (FFlag::LuauAstTypeGroup3)
4138
- {
4139
- auto parenthesizedType = explicitTypePack->typeList .types .data [0 ];
4140
- parameters.push_back (
4141
- {parseTypeSuffix (allocator.alloc <AstTypeGroup>(parenthesizedType->location , parenthesizedType), begin), {}}
4142
- );
4143
- }
4144
- else
4145
- parameters.push_back ({parseTypeSuffix (explicitTypePack->typeList .types .data [0 ], begin), {}});
4125
+ auto parenthesizedType = explicitTypePack->typeList .types .data [0 ];
4126
+ parameters.push_back (
4127
+ {parseTypeSuffix (allocator.alloc <AstTypeGroup>(parenthesizedType->location , parenthesizedType), begin), {}}
4128
+ );
4146
4129
}
4147
4130
else
4148
- {
4149
- // Otherwise, it's a type pack.
4150
- parameters.push_back ({{}, typePack});
4151
- }
4131
+ parameters.push_back ({parseTypeSuffix (explicitTypePack->typeList .types .data [0 ], begin), {}});
4152
4132
}
4153
4133
else
4154
4134
{
4155
- // There's two cases in which `typePack` will be null:
4156
- // - We try to parse a simple type or a type pack, and
4157
- // we get a simple type: there's no ambiguity and
4158
- // we attempt to parse a complex type.
4159
- // - The next lexeme was a `|` or `&` indicating a
4160
- // union or intersection type with a leading
4161
- // separator. We just fall right into
4162
- // `parseTypeSuffix`, which allows its first
4163
- // argument to be `nullptr`
4164
- parameters.push_back ({parseTypeSuffix (type, begin), {}});
4135
+ // Otherwise, it's a type pack.
4136
+ parameters.push_back ({{}, typePack});
4165
4137
}
4166
4138
}
4167
4139
else
4168
4140
{
4169
- auto [type, typePack] = parseSimpleTypeOrPack ();
4170
-
4171
- if (typePack)
4172
- parameters.push_back ({{}, typePack});
4173
- else
4174
- parameters.push_back ({type, {}});
4141
+ // There's two cases in which `typePack` will be null:
4142
+ // - We try to parse a simple type or a type pack, and
4143
+ // we get a simple type: there's no ambiguity and
4144
+ // we attempt to parse a complex type.
4145
+ // - The next lexeme was a `|` or `&` indicating a
4146
+ // union or intersection type with a leading
4147
+ // separator. We just fall right into
4148
+ // `parseTypeSuffix`, which allows its first
4149
+ // argument to be `nullptr`
4150
+ parameters.push_back ({parseTypeSuffix (type, begin), {}});
4175
4151
}
4176
4152
}
4177
4153
else if (lexer.current ().type == ' >' && parameters.empty ())
0 commit comments