Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Additional Detail from JIRA
Bug, DiagnosticsQoI, Parser, StarterBug
A standalone do block without the optional catch block, followed by a while block will generate the error "'do-while' statement is not allowed; use 'repeat-while' instead". This is caused by a diagnostic for dealing with legacy code using "do-while". The error disappears if the statements are separated with a semicolon.
The diagnostic could be improved by suggesting the semicolon or taking the separating newlines into account. cc @belkadan
The text was updated successfully, but these errors were encountered:
The semicolon would be sufficient, but it's not really standard Swift, and it would stand out in a function with no other semicolons. I'd go for suggesting the extra newline myself; Rintaro may also have suggestions.
Swift doesn't have do-while loops at all anymore, so we're just trying to decide when to emit the diagnostic. If the compiler can guess that the developer probably didn't write a do-while loop by accident (and was instead using a do block followed by a normal while loop), then it can just not emit the diagnostic.