Skip to content

Commit 47e57d8

Browse files
Update atStartOfConditionalStatementBody
1 parent ab8ad58 commit 47e57d8

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

Sources/SwiftParser/Statements.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,14 +1080,6 @@ extension Parser.Lookahead {
10801080
}
10811081
if self.atStartOfLine {
10821082
// If the current token is at the start of a line, it is most likely a statement body. The only exceptions are:
1083-
if self.at(.leftBrace) && withLookahead({ $0.atStartOfConditionalStatementBody() }) {
1084-
// If a statement body starts after this on, we actually have a closure followed by the statement body e.g.
1085-
// if true, { true }
1086-
// {
1087-
// print("body")
1088-
// }
1089-
return false
1090-
}
10911083
if self.at(.comma) {
10921084
// If newline begins with ',' it must be a condition trailing comma, so this can't be the statement body, e.g.
10931085
// if true, { true }

Tests/SwiftParserTest/TrailingCommaTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ final class TrailingCommaTests: ParserTestCase {
137137
""",
138138
substructure: IfExprSyntax(
139139
conditions: [
140-
ConditionElementSyntax.init(condition: .expression("true"), trailingComma: .commaToken()),
141-
ConditionElementSyntax.init(condition: .expression("{ true }"), trailingComma: nil),
140+
ConditionElementSyntax.init(condition: .expression("true"), trailingComma: .commaToken())
142141
],
143-
body: "{ print(0) }"
142+
body: "{ true }"
144143
)
145144
)
146145

0 commit comments

Comments
 (0)