@@ -1810,14 +1810,14 @@ final class RecoveryTests: ParserTestCase {
1810
1810
assertParse (
1811
1811
"""
1812
1812
struct ErrorInFunctionSignatureResultArrayType2 1️⃣{
1813
- func foo() -> Int2️⃣[0 {
1813
+ func foo() -> Int2️⃣[0 3️⃣ {
1814
1814
return [0]
1815
- }3️⃣
1816
- 4️⃣ }
1815
+ }4️⃣
1816
+ 5️⃣ }
1817
1817
""" ,
1818
1818
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.
1821
1821
DiagnosticSpec (
1822
1822
locationMarker: " 2️⃣ " ,
1823
1823
message: " expected '}' to end struct " ,
@@ -1826,19 +1826,24 @@ final class RecoveryTests: ParserTestCase {
1826
1826
) ,
1827
1827
DiagnosticSpec (
1828
1828
locationMarker: " 3️⃣ " ,
1829
+ message: " expected ',' in array element " ,
1830
+ fixIts: [ " insert ',' " ]
1831
+ ) ,
1832
+ DiagnosticSpec (
1833
+ locationMarker: " 4️⃣ " ,
1829
1834
message: " expected ']' to end array " ,
1830
1835
notes: [ NoteSpec ( locationMarker: " 2️⃣ " , message: " to match this opening '[' " ) ] ,
1831
1836
fixIts: [ " insert ']' " ]
1832
1837
) ,
1833
1838
DiagnosticSpec (
1834
- locationMarker: " 4️⃣ " ,
1839
+ locationMarker: " 5️⃣ " ,
1835
1840
message: " extraneous brace at top level "
1836
1841
) ,
1837
1842
] ,
1838
1843
fixedSource: """
1839
1844
struct ErrorInFunctionSignatureResultArrayType2 {
1840
1845
func foo() -> Int
1841
- }[0 {
1846
+ }[0, {
1842
1847
return [0]
1843
1848
}]
1844
1849
}
@@ -1895,11 +1900,12 @@ final class RecoveryTests: ParserTestCase {
1895
1900
assertParse (
1896
1901
"""
1897
1902
struct ErrorInFunctionSignatureResultArrayType11 ℹ️{
1898
- func foo() -> Int1️⃣[(a){a++}] {
1903
+ func foo() -> Int1️⃣[(a){a++}]2️⃣ {
1899
1904
}
1900
- 2️⃣ }
1905
+ 3️⃣ }
1901
1906
""" ,
1902
1907
diagnostics: [
1908
+ // TODO: We should just recover to `{` with `[(a){a++}]` becoming unexpected.
1903
1909
DiagnosticSpec (
1904
1910
locationMarker: " 1️⃣ " ,
1905
1911
message: " expected '}' to end struct " ,
@@ -1908,13 +1914,19 @@ final class RecoveryTests: ParserTestCase {
1908
1914
) ,
1909
1915
DiagnosticSpec (
1910
1916
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️⃣ " ,
1911
1922
message: " extraneous brace at top level "
1912
1923
) ,
1913
1924
] ,
1914
1925
fixedSource: """
1915
1926
struct ErrorInFunctionSignatureResultArrayType11 {
1916
1927
func foo() -> Int
1917
- }[(a){a++}] {
1928
+ }[(a){a++}]
1929
+ {
1918
1930
}
1919
1931
}
1920
1932
"""
0 commit comments