File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Tests/SwiftParserTest/translated Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -318,10 +318,8 @@ extension Parser {
318
318
)
319
319
320
320
let rhs : RawExprSyntax ?
321
- if colon. isMissing {
322
- // If the colon is missing there's not much more structure we can
323
- // expect out of this expression sequence. Emit a missing expression
324
- // to end the parsing here.
321
+ if colon. isMissing,
322
+ currentToken. rawTokenKind != currentToken. cursor. previousTokenKind {
325
323
rhs = RawExprSyntax ( RawMissingExprSyntax ( arena: self . arena) )
326
324
} else {
327
325
rhs = nil
Original file line number Diff line number Diff line change @@ -69,4 +69,15 @@ final class InvalidIfExprTests: XCTestCase {
69
69
)
70
70
}
71
71
72
+ func testInvalidIfExpr5( ) {
73
+ assertParse (
74
+ """
75
+ foo ? 1 1️⃣2
76
+ """ ,
77
+ diagnostics: [
78
+ DiagnosticSpec ( message: " expected ':' after '? ...' in ternary expression " , fixIts: [ " insert ':' " ] )
79
+ ] ,
80
+ fixedSource: " foo ? 1 : 2 "
81
+ )
82
+ }
72
83
}
You can’t perform that action at this time.
0 commit comments