File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -2231,11 +2231,7 @@ extension Parser.Lookahead {
2231
2231
2232
2232
// Skip by a closure capture list if present.
2233
2233
if lookahead. consume ( if: . leftSquareBracket) != nil {
2234
- var captureListProgress = LoopProgressCondition ( )
2235
- while !lookahead. at ( any: [ . eof, . rightSquareBracket] ) && captureListProgress. evaluate ( lookahead. currentToken) {
2236
- lookahead. consumeAnyToken ( )
2237
- }
2238
-
2234
+ lookahead. skipUntil ( . rightSquareBracket, . rightSquareBracket)
2239
2235
if lookahead. consume ( if: . rightSquareBracket) == nil {
2240
2236
return false
2241
2237
}
Original file line number Diff line number Diff line change @@ -593,4 +593,21 @@ final class ExpressionTests: XCTestCase {
593
593
substructureAfterMarker: " PLUS "
594
594
)
595
595
}
596
+
597
+ func testBogusCaptureLists( ) {
598
+ // N.B. This test ensures that capture list lookahead doesn't try to pair
599
+ // the opening square bracket from the array literal with the closing
600
+ // square bracket from the capture list.
601
+ AssertParse (
602
+ """
603
+ {
604
+ [
605
+ AboutItem(title: TextContent.legalAndMore, accessoryType: .disclosureIndicator, action: { [weak self] context in
606
+ self?.tracker.buttonPressed(.legal)
607
+ context.showSubmenu(title: TextContent.legalAndMore, configuration: LegalAndMoreSubmenuConfiguration())
608
+ }),
609
+ ]
610
+ }()
611
+ """ )
612
+ }
596
613
}
You can’t perform that action at this time.
0 commit comments