@@ -1810,14 +1810,14 @@ final class RecoveryTests: ParserTestCase {
18101810 assertParse (
18111811 """
18121812 struct ErrorInFunctionSignatureResultArrayType2 1️⃣{
1813- func foo() -> Int2️⃣[0 {
1813+ func foo() -> Int2️⃣[0 3️⃣ {
18141814 return [0]
1815- }3️⃣
1816- 4️⃣ }
1815+ }4️⃣
1816+ 5️⃣ }
18171817 """ ,
18181818 diagnostics: [
1819- // TODO: Old parser expected error on line 2: expected ']' in array type
1820- // TODO: Old parser expected note on line 2: to match this opening '['
1819+ // TODO: Old parser expected error to add `]` on line 2, but we should just recover to
1820+ // `{` with `[0` becoming unexpected.
18211821 DiagnosticSpec (
18221822 locationMarker: " 2️⃣ " ,
18231823 message: " expected '}' to end struct " ,
@@ -1826,19 +1826,24 @@ final class RecoveryTests: ParserTestCase {
18261826 ) ,
18271827 DiagnosticSpec (
18281828 locationMarker: " 3️⃣ " ,
1829+ message: " expected ',' in array element " ,
1830+ fixIts: [ " insert ',' " ]
1831+ ) ,
1832+ DiagnosticSpec (
1833+ locationMarker: " 4️⃣ " ,
18291834 message: " expected ']' to end array " ,
18301835 notes: [ NoteSpec ( locationMarker: " 2️⃣ " , message: " to match this opening '[' " ) ] ,
18311836 fixIts: [ " insert ']' " ]
18321837 ) ,
18331838 DiagnosticSpec (
1834- locationMarker: " 4️⃣ " ,
1839+ locationMarker: " 5️⃣ " ,
18351840 message: " extraneous brace at top level "
18361841 ) ,
18371842 ] ,
18381843 fixedSource: """
18391844 struct ErrorInFunctionSignatureResultArrayType2 {
18401845 func foo() -> Int
1841- }[0 {
1846+ }[0, {
18421847 return [0]
18431848 }]
18441849 }
@@ -1895,11 +1900,12 @@ final class RecoveryTests: ParserTestCase {
18951900 assertParse (
18961901 """
18971902 struct ErrorInFunctionSignatureResultArrayType11 ℹ️{
1898- func foo() -> Int1️⃣[(a){a++}] {
1903+ func foo() -> Int1️⃣[(a){a++}]2️⃣ {
18991904 }
1900- 2️⃣ }
1905+ 3️⃣ }
19011906 """ ,
19021907 diagnostics: [
1908+ // TODO: We should just recover to `{` with `[(a){a++}]` becoming unexpected.
19031909 DiagnosticSpec (
19041910 locationMarker: " 1️⃣ " ,
19051911 message: " expected '}' to end struct " ,
@@ -1908,13 +1914,19 @@ final class RecoveryTests: ParserTestCase {
19081914 ) ,
19091915 DiagnosticSpec (
19101916 locationMarker: " 2️⃣ " ,
1917+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1918+ fixIts: [ " insert newline " , " insert ';' " ]
1919+ ) ,
1920+ DiagnosticSpec (
1921+ locationMarker: " 3️⃣ " ,
19111922 message: " extraneous brace at top level "
19121923 ) ,
19131924 ] ,
19141925 fixedSource: """
19151926 struct ErrorInFunctionSignatureResultArrayType11 {
19161927 func foo() -> Int
1917- }[(a){a++}] {
1928+ }[(a){a++}]
1929+ {
19181930 }
19191931 }
19201932 """
0 commit comments