Skip to content

Commit c624b79

Browse files
committed
Accept Empty Capture Lists
1 parent 62ef5c0 commit c624b79

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Sources/SwiftParser/Expressions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ extension Parser {
18011801
// At this point, we know we have a closure signature. Parse the capture list
18021802
// and parameters.
18031803
var elements = [RawClosureCaptureItemSyntax]()
1804-
do {
1804+
if !self.at(.rightSquareBracket) {
18051805
var keepGoing: RawTokenSyntax? = nil
18061806
var loopProgress = LoopProgressCondition()
18071807
repeat {

Tests/SwiftParserTest/LexerTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ public class LexerTests: XCTestCase {
560560
lexeme(.eof, "\n\n///", leading: 5),
561561
])
562562
}
563-
}
564563

565-
func testLex() {
566564
do {
567565
var data =
568566
"""

Tests/SwiftParserTest/Types.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ final class TypeTests: XCTestCase {
3636
}
3737

3838
func testClosureSignatures() throws {
39+
40+
AssertParse(
41+
"""
42+
simple { [] str in
43+
print("closure with empty capture list")
44+
}
45+
""")
46+
3947
AssertParse("""
4048
{ ()
4149
throws -> Void in }

0 commit comments

Comments
 (0)