@@ -59,7 +59,7 @@ extension Parser {
5959}
6060
6161extension Parser {
62- mutating func parseCodeBlockItemList( isAtTopLevel: Bool , allowInitDecl: Bool = true , stopCondition: ( inout Parser ) -> Bool ) -> RawCodeBlockItemListSyntax {
62+ mutating func parseCodeBlockItemList( isAtTopLevel: Bool = false , allowInitDecl: Bool = true , until stopCondition: ( inout Parser ) -> Bool ) -> RawCodeBlockItemListSyntax {
6363 var elements = [ RawCodeBlockItemSyntax] ( )
6464 var loopProgress = LoopProgressCondition ( )
6565 while !stopCondition( & self ) , loopProgress. evaluate ( currentToken) {
@@ -89,7 +89,7 @@ extension Parser {
8989 ///
9090 /// top-level-declaration → statements?
9191 mutating func parseTopLevelCodeBlockItems( ) -> RawCodeBlockItemListSyntax {
92- return parseCodeBlockItemList ( isAtTopLevel: true , stopCondition : { _ in false } )
92+ return parseCodeBlockItemList ( isAtTopLevel: true , until : { _ in false } )
9393 }
9494
9595 /// The optional form of `parseCodeBlock` that checks to see if the parser has
@@ -116,7 +116,7 @@ extension Parser {
116116 /// indented to close this code block or a surrounding context. See `expectRightBrace`.
117117 mutating func parseCodeBlock( introducer: RawTokenSyntax ? = nil , allowInitDecl: Bool = true ) -> RawCodeBlockSyntax {
118118 let ( unexpectedBeforeLBrace, lbrace) = self . expect ( . leftBrace)
119- let itemList = parseCodeBlockItemList ( isAtTopLevel : false , allowInitDecl: allowInitDecl, stopCondition : { $0. at ( . rightBrace) } )
119+ let itemList = parseCodeBlockItemList ( allowInitDecl: allowInitDecl, until : { $0. at ( . rightBrace) } )
120120 let ( unexpectedBeforeRBrace, rbrace) = self . expectRightBrace ( leftBrace: lbrace, introducer: introducer)
121121
122122 return . init(
@@ -148,7 +148,7 @@ extension Parser {
148148 /// statement → compiler-control-statement
149149 /// statements → statement statements?
150150 @_spi ( RawSyntax)
151- public mutating func parseCodeBlockItem( isAtTopLevel: Bool = false , allowInitDecl: Bool = true ) -> RawCodeBlockItemSyntax ? {
151+ public mutating func parseCodeBlockItem( isAtTopLevel: Bool , allowInitDecl: Bool ) -> RawCodeBlockItemSyntax ? {
152152 if let remainingTokens = remainingTokensIfMaximumNestingLevelReached ( ) {
153153 return RawCodeBlockItemSyntax (
154154 remainingTokens,
@@ -229,7 +229,7 @@ extension Parser {
229229 // If config of attributes is parsed as part of declaration parsing as it
230230 // doesn't constitute its own code block item.
231231 let directive = self . parsePoundIfDirective { ( parser, _) in
232- parser. parseCodeBlockItem ( )
232+ parser. parseCodeBlockItem ( isAtTopLevel : false , allowInitDecl : true )
233233 } addSemicolonIfNeeded: { lastElement, newItemAtStartOfLine, parser in
234234 if lastElement. semicolon == nil && !newItemAtStartOfLine {
235235 return RawCodeBlockItemSyntax (
0 commit comments