Skip to content

Commit 1e51b70

Browse files
committed
Fix generic parameter round trip failure
Fixes #835 Resolves rdar://100321071
1 parent 0d39242 commit 1e51b70

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ extension Parser {
302302
let attributes = self.parseAttributeList()
303303

304304
let (unexpectedBeforeName, name) = self.expectIdentifier()
305-
if unexpectedBeforeName == nil && name.isMissing && elements.isEmpty {
305+
if attributes == nil && unexpectedBeforeName == nil && name.isMissing && elements.isEmpty {
306306
break
307307
}
308308

Tests/SwiftParserTest/Declarations.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,21 @@ final class DeclarationTests: XCTestCase {
10591059
}
10601060
""")
10611061
}
1062+
1063+
func testStandaloneAtSignInGenericParameter() {
1064+
AssertParse(
1065+
"""
1066+
struct U<@#^DIAG^#
1067+
""",
1068+
diagnostics: [
1069+
DiagnosticSpec(message: "Expected name of attribute"),
1070+
DiagnosticSpec(message: "Expected identifier in generic parameter"),
1071+
DiagnosticSpec(message: "Expected '>' to end generic parameter clause"),
1072+
DiagnosticSpec(message: "Expected '{' to start struct"),
1073+
DiagnosticSpec(message: "Expected '}' to end struct"),
1074+
]
1075+
)
1076+
}
10621077
}
10631078

10641079
extension Parser.DeclAttributes {

0 commit comments

Comments
 (0)