@@ -18,9 +18,6 @@ LUAU_FASTINTVARIABLE(LuauParseErrorLimit, 100)
1818// flag so that we don't break production games by reverting syntax changes.
1919// See docs/SyntaxChanges.md for an explanation.
2020LUAU_FASTFLAGVARIABLE(LuauSolverV2)
21- LUAU_FASTFLAGVARIABLE(LuauAllowComplexTypesInGenericParams)
22- LUAU_FASTFLAGVARIABLE(LuauErrorRecoveryForTableTypes)
23- LUAU_FASTFLAGVARIABLE(LuauExtendStatEndPosWithSemicolon)
2421LUAU_FASTFLAGVARIABLE(LuauStoreCSTData2)
2522LUAU_FASTFLAGVARIABLE(LuauPreserveUnionIntersectionNodeForLeadingTokenSingleType)
2623LUAU_FASTFLAGVARIABLE(LuauAstTypeGroup3)
@@ -204,7 +201,9 @@ ParseExprResult Parser::parseExpr(const char* buffer, size_t bufferSize, AstName
204201 AstExpr* expr = p.parseExpr ();
205202 size_t lines = p.lexer .current ().location .end .line + (bufferSize > 0 && buffer[bufferSize - 1 ] != ' \n ' );
206203
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+ };
208207 }
209208 catch (ParseError& err)
210209 {
@@ -316,10 +315,7 @@ AstStatBlock* Parser::parseBlockNoScope()
316315 {
317316 nextLexeme ();
318317 stat->hasSemicolon = true ;
319- if (FFlag::LuauExtendStatEndPosWithSemicolon)
320- {
321- stat->location .end = lexer.previousLocation ().end ;
322- }
318+ stat->location .end = lexer.previousLocation ().end ;
323319 }
324320
325321 body.push_back (stat);
@@ -745,14 +741,7 @@ AstExpr* Parser::parseFunctionName(bool& hasself, AstName& debugname)
745741 // while we could concatenate the name chain, for now let's just write the short name
746742 debugname = name.name ;
747743
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, ' .' );
756745
757746 // note: while the parser isn't recursive here, we're generating recursive structures of unbounded depth
758747 incrementRecursionCounter (" function name" );
@@ -771,14 +760,7 @@ AstExpr* Parser::parseFunctionName(bool& hasself, AstName& debugname)
771760 // while we could concatenate the name chain, for now let's just write the short name
772761 debugname = name.name ;
773762
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, ' :' );
782764
783765 hasself = true ;
784766 }
@@ -1666,13 +1648,12 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
16661648
16671649 auto * cstNode = FFlag::LuauStoreCSTData2 && options.storeCstData ? allocator.alloc <CstExprFunction>() : nullptr ;
16681650
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 );
16761657
16771658 MatchLexeme matchParen = lexer.current ();
16781659 expectAndConsume (' (' , " function" );
@@ -1687,8 +1668,7 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
16871668 //
16881669 // function (t: { a: number }) end
16891670 //
1690- if (FFlag::LuauErrorRecoveryForTableTypes)
1691- matchRecoveryStopOnToken[' )' ]++;
1671+ matchRecoveryStopOnToken[' )' ]++;
16921672
16931673 TempVector<Binding> args (scratchBinding);
16941674
@@ -1707,8 +1687,7 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
17071687
17081688 expectMatchAndConsume (' )' , matchParen, true );
17091689
1710- if (FFlag::LuauErrorRecoveryForTableTypes)
1711- matchRecoveryStopOnToken[' )' ]--;
1690+ matchRecoveryStopOnToken[' )' ]--;
17121691
17131692 std::optional<AstTypeList> typelist = parseOptionalReturnType (cstNode ? &cstNode->returnSpecifierPosition : nullptr );
17141693
@@ -1822,7 +1801,12 @@ Parser::Binding Parser::parseBinding()
18221801}
18231802
18241803// 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+ )
18261810{
18271811 TempVector<Position> localCommaPositions (scratchPosition);
18281812
@@ -2185,6 +2169,7 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
21852169 if (FFlag::LuauStoreCSTData2 && options.storeCstData )
21862170 std::tie (style, blockDepth) = extractStringDetails ();
21872171
2172+ Position stringPosition = lexer.current ().location .begin ;
21882173 AstArray<char > sourceString;
21892174 std::optional<AstArray<char >> chars = parseCharArray (options.storeCstData ? &sourceString : nullptr );
21902175
@@ -2209,7 +2194,8 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
22092194 colonPosition,
22102195 tableSeparator (),
22112196 lexer.current ().location .begin ,
2212- allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth)
2197+ allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth),
2198+ stringPosition
22132199 });
22142200 }
22152201 else
@@ -2300,6 +2286,7 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
23002286 if (FFlag::LuauStoreCSTData2 && options.storeCstData )
23012287 std::tie (style, blockDepth) = extractStringDetails ();
23022288
2289+ Position stringPosition = lexer.current ().location .begin ;
23032290 AstArray<char > sourceString;
23042291 std::optional<AstArray<char >> chars = parseCharArray (options.storeCstData ? &sourceString : nullptr );
23052292
@@ -2324,7 +2311,8 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
23242311 colonPosition,
23252312 tableSeparator (),
23262313 lexer.current ().location .begin ,
2327- allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth)
2314+ allocator.alloc <CstExprConstantString>(sourceString, style, blockDepth),
2315+ stringPosition
23282316 });
23292317 }
23302318 else
@@ -2420,7 +2408,7 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
24202408
24212409 Location end = lexer.current ().location ;
24222410
2423- if (!expectMatchAndConsume (' }' , matchBrace, /* searchForMissing = */ FFlag::LuauErrorRecoveryForTableTypes ))
2411+ if (!expectMatchAndConsume (' }' , matchBrace, /* searchForMissing = */ true ))
24242412 end = lexer.previousLocation ();
24252413
24262414 if (FFlag::LuauStoreCSTData2)
@@ -4100,78 +4088,66 @@ AstArray<AstTypeOrPack> Parser::parseTypeParams(Position* openingPosition, TempV
41004088 }
41014089 else if (lexer.current ().type == ' (' )
41024090 {
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 ;
41094095
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+ }
41164102
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.
41254111
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 ))
41274117 {
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)
41314124 {
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+ );
41464129 }
41474130 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), {}});
41524132 }
41534133 else
41544134 {
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});
41654137 }
41664138 }
41674139 else
41684140 {
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), {}});
41754151 }
41764152 }
41774153 else if (lexer.current ().type == ' >' && parameters.empty ())
0 commit comments