File tree Expand file tree Collapse file tree 2 files changed +38
-4
lines changed Expand file tree Collapse file tree 2 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -491,11 +491,9 @@ extension Parser {
491
491
mutating func parseSpecializeAttributeSpecList( ) -> RawSpecializeAttributeSpecListSyntax {
492
492
var elements = [ RawSyntax] ( )
493
493
// Parse optional "exported" and "kind" labeled parameters.
494
- while !self . at ( . eof) && !self . at ( . whereKeyword) {
494
+ while !self . at ( . eof) && !self . at ( . rightParen ) && ! self . at ( . whereKeyword) {
495
495
let ident = self . parseAnyIdentifier ( )
496
- guard let knownParameter = SpecializeParameter ( rawValue: ident. tokenText) else {
497
- fatalError ( )
498
- }
496
+ let knownParameter = SpecializeParameter ( rawValue: ident. tokenText)
499
497
let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
500
498
501
499
switch knownParameter {
@@ -573,6 +571,17 @@ extension Parser {
573
571
trailingComma: comma,
574
572
arena: self . arena
575
573
) ) )
574
+ case nil :
575
+ let valueLabel = self . consumeAnyToken ( )
576
+ let comma = self . consume ( if: . comma)
577
+ elements. append ( RawSyntax ( RawLabeledSpecializeEntrySyntax (
578
+ label: ident,
579
+ unexpectedBeforeColon,
580
+ colon: colon,
581
+ value: valueLabel,
582
+ trailingComma: comma,
583
+ arena: self . arena
584
+ ) ) )
576
585
}
577
586
}
578
587
Original file line number Diff line number Diff line change @@ -32,4 +32,29 @@ final class AttributeTests: XCTestCase {
32
32
]
33
33
)
34
34
}
35
+
36
+ func testMissingClosingParenToAttribute( ) {
37
+ AssertParse (
38
+ """
39
+ @_specialize(e#^DIAG_1^#
40
+ """ ,
41
+ diagnostics: [
42
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Expected ':' in attribute argument " ) ,
43
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Expected ')' to end attribute " ) ,
44
+ ]
45
+ )
46
+ }
47
+
48
+ func testMultipleInvalidSpecializeParams( ) {
49
+ AssertParse (
50
+ """
51
+ @_specialize(e#^DIAG_1^#, exported#^DIAG_2^#)
52
+ """ ,
53
+ diagnostics: [
54
+ DiagnosticSpec ( locationMarker: " DIAG_1 " , message: " Expected ':' in attribute argument " ) ,
55
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected ':' in attribute argument " ) ,
56
+ DiagnosticSpec ( locationMarker: " DIAG_2 " , message: " Expected 'false' in attribute argument " ) ,
57
+ ]
58
+ )
59
+ }
35
60
}
You can’t perform that action at this time.
0 commit comments