Skip to content

Commit a7fa220

Browse files
authored
Merge pull request #2424 from ahoppen/ahoppen/skip-newlines-for-weak-bracket-close
Skip newlines for `weakBracketClose` precedence level
2 parents 92159bc + 616f2d0 commit a7fa220

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ enum TokenPrecedence: Comparable {
100100
return precedence(lhs) < precedence(rhs)
101101
}
102102

103-
/// When expecting a token with `stmtKeyword` precedence or higher, newlines may be skipped to find that token.
103+
/// When expecting a token with `weakBracketClose` precedence or higher, newlines may be skipped to find that token.
104104
/// For lower precedence groups, we consider newlines the end of the lookahead scope.
105105
var shouldSkipOverNewlines: Bool {
106-
return self >= .stmtKeyword
106+
return self >= .weakBracketClose
107107
}
108108

109109
init(_ lexeme: Lexer.Lexeme) {

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,10 @@ final class DeclarationTests: ParserTestCase {
486486
) var a = 0
487487
""",
488488
diagnostics: [
489-
DiagnosticSpec(message: "expected 'set)' to end modifier", fixIts: ["insert 'set)'"]),
490-
// FIXME: It should print `+` as detail of text.
491-
DiagnosticSpec(message: "unexpected code in variable"),
489+
DiagnosticSpec(message: "expected 'set' in modifier", fixIts: ["remove '+'"])
492490
],
493491
fixedSource: """
494-
private(set) +
492+
private(
495493
set
496494
) var a = 0
497495
"""
@@ -1476,19 +1474,13 @@ final class DeclarationTests: ParserTestCase {
14761474
message: "expected ':' in parameter",
14771475
fixIts: ["insert ':'"]
14781476
),
1479-
DiagnosticSpec(
1480-
locationMarker: "2️⃣",
1481-
message: "expected ')' to end parameter clause",
1482-
notes: [NoteSpec(message: "to match this opening '('")],
1483-
fixIts: ["insert ')'"]
1484-
),
14851477
DiagnosticSpec(
14861478
locationMarker: "3️⃣",
1487-
message: "extraneous code ': Int) {}' at top level"
1479+
message: "unexpected code ': Int' in parameter clause"
14881480
),
14891481
],
14901482
fixedSource: """
1491-
func foo(first second: third)
1483+
func foo(first second: third
14921484
: Int) {}
14931485
"""
14941486
)

0 commit comments

Comments
 (0)