Skip to content
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

Don't throw WarningCode.EmptyBlock on semicolon bodies #1491

Closed

Conversation

ZeWaka
Copy link
Collaborator

@ZeWaka ZeWaka commented Oct 15, 2023

Essentially, throw WarningCode.EmptyBlock on

if(xyz)
	// :(
else
	...

but not

if(xyz)
	; // <--
else
	...

This way, developers can insert a semicolon to denote that they intentionally want to write a statement a certain way.


this is pretty cursed code, but it's the only really viable way i could see how to do this

/// This is used to determine if we should flag for <c>WarningCode.EmptyBlock</c>,
/// which we don't do if there was a manually entered semicolon within.
/// </summary>
public bool NotCompletelyEmpty;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

definitely open to a wording change on this

@@ -2616,5 +2639,19 @@ public partial class DMParser : Parser<Token> {

return hasDelimiter;
}

private bool DelimiterHasSemicolon(ref bool hasSemicolon) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also this

@ZeWaka ZeWaka requested a review from wixoaGit October 23, 2023 20:41
@ZeWaka
Copy link
Collaborator Author

ZeWaka commented Oct 24, 2023

wixoa: What if we instead had something in our AST to represent an "empty statement"?

note

@ZeWaka ZeWaka force-pushed the feature/empty-block-semicolon branch from cc85bee to d63de28 Compare January 15, 2024 19:39
@ZeWaka ZeWaka marked this pull request as draft January 15, 2024 21:44
@wixoaGit
Copy link
Member

Closing in favor of #1670

@wixoaGit wixoaGit closed this Feb 12, 2024
@ZeWaka ZeWaka deleted the feature/empty-block-semicolon branch February 12, 2024 19:30
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