Skip to content

Diagnose ';' statements #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2022
Merged

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 10, 2022

Add diagnostics for code block items that only contain a semicolon.

Add diagnostics for code block items that only contain a semicolon.
@ahoppen ahoppen requested a review from bnbarham October 10, 2022 09:14
@ahoppen
Copy link
Member Author

ahoppen commented Oct 10, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit 0cd98af into swiftlang:main Oct 10, 2022
@ahoppen ahoppen deleted the ahoppen/semi-statements branch October 10, 2022 12:52
@@ -72,6 +72,7 @@ public enum StaticParserError: String, DiagnosticMessage {
case editorPlaceholderInSourceFile = "editor placeholder in source file"
case missingColonInTernaryExprDiagnostic = "expected ':' after '? ...' in ternary expression"
case missingFunctionParameterClause = "expected argument list in function declaration"
case stanaloneSemicolonStatement = "';' statements are not allowed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case stanaloneSemicolonStatement = "';' statements are not allowed"
case standaloneSemicolonStatement = "';' statements are not allowed"

Also I know this is what the old diagnostic was, but could we add standalone to the start? We could also make some better suggestions depending on the context, ie. in a switch suggest break. Possibly fallthrough as well, though that's semantically different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the typo, also adding “standalone” to the error message makes sense to me. The Fix-It to replace it with break doesn’t really seem worth it. I don’t think there are very many C developers switching to Swift anymore that are expecting ';' statements to work around the requirement that switch cases must have an executable statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants