Skip to content

Disallow empty statements made by semicolons#6886

Merged
WalterBright merged 2 commits intodlang:masterfrom
Burgos:semicolon-yeah
Jun 13, 2017
Merged

Disallow empty statements made by semicolons#6886
WalterBright merged 2 commits intodlang:masterfrom
Burgos:semicolon-yeah

Conversation

@Burgos
Copy link
Contributor

@Burgos Burgos commented Jun 10, 2017

This turns the previous warning when using a semicolon
for an empty statement to a compilation error.

src/ddmd/parse.d Outdated
if (f.frequire || f.fensure)
error("missing body { ... } after in or out");
f.fbody = parseStatement(PSsemi);
f.fbody = parseStatement(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to make a new enum value PSdefault or so, but I saw parseStatement called with 0 in other places as well, so I left it like this.

@Burgos Burgos force-pushed the semicolon-yeah branch 2 times, most recently from 8780ce4 to c03d4ca Compare June 10, 2017 21:37
src/ddmd/parse.d Outdated
warning(loc, "use '{ }' for an empty statement, not a ';'");
else
error("use '{ }' for an empty statement, not a ';'");
error("use '{ }' for an empty statement, not a ';'");
Copy link

@ghost ghost Jun 10, 2017

Choose a reason for hiding this comment

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

You cant pass from warning to error. There must be a deprecation period before.

@WalterBright
Copy link
Member

This must go through a period of time where it is deprecated first.

@Burgos
Copy link
Contributor Author

Burgos commented Jun 11, 2017

Ah, true. I got mislead by the compiler's source, which states this is deprecated (See the PSsemi's ddoc). Will fix, thanks!

Creating empty statements using semicolons, for which
was previously issued a warning is now causing a deprecation
hint.
There were places in the tests where the empty statements
were produces, which is now a compilation error. This removes/replaces
all of them with {}.
@Burgos
Copy link
Contributor Author

Burgos commented Jun 11, 2017

Changed to a deprecation.

Copy link
Member

@WalterBright WalterBright left a comment

Choose a reason for hiding this comment

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

Nice work!

@Burgos
Copy link
Contributor Author

Burgos commented Jun 12, 2017

I'm not sure what's up with Jenkins, but he also failed in the trivial #6891 PR

@wilzbach
Copy link
Contributor

I'm not sure what's up with Jenkins, but he also failed in the trivial #6891 PR

Yes, the Jenkins server was down for a week and now we are playing goose hunting for the introduced regressions in downstream projects, see e.g. dlang/phobos#5469
tl;dr: don't worry about it, the errors should be fixed soon.

@nemanja-boric-sociomantic
Copy link
Contributor

All clear, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants