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

Expected compile error because bad use of semicolon #28157

Closed
wilcus opened this Issue Sep 1, 2015 · 9 comments

Comments

Projects
None yet
7 participants
@wilcus
Copy link

wilcus commented Sep 1, 2015

Actual result compile and output "bogus"

Code:
https://pastebin.mozilla.org/8844697

rustc 1.4.0-dev (7b7fc67 2015-08-13)

@jonas-schievink

This comment has been minimized.

Copy link
Member

jonas-schievink commented Sep 1, 2015

Code in question:

fn main(){
  if 4==4{;
    println!("bogus");
  }
}

The grammar docs indeed disallow a bare ;.

@arielb1 arielb1 added the A-parser label Sep 2, 2015

fhahn added a commit to fhahn/rust that referenced this issue Oct 21, 2015

fhahn added a commit to fhahn/rust that referenced this issue Oct 21, 2015

fhahn added a commit to fhahn/rust that referenced this issue Oct 21, 2015

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 21, 2015

triage: I-nominated

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 21, 2015

There's a PR to fix this issue (#29215), but as it's a language change I wanted to circulate among the lang team to ensure that it's intended.

(fwiw I would personally consider this behavior fine, as shown by the fall out in the PR it's often convenient to rely on this in contexts like with macros)

@fhahn

This comment has been minimized.

Copy link
Contributor

fhahn commented Oct 22, 2015

If this comes out as wontfix, I think it still would make sense to remove the trailing semicolons after the few function definitions. I would also be happy to update the documentation and the reference parser.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 23, 2015

We discussed in the @rust-lang/lang and came to the conclusion that parsing an empty semicolon here is not a bug and we should not attempt to issue warnings or make it an error. In fact, most of us rather expected it to work, perhaps because of C precendent.

However, @nrc pointed out that a clippy lint might be suitable or -- perhaps better yet -- modifying rustfmt to drop such statements. I too would personally prefer to have rustfmt silently clean things up behind my back than to have to some lint nag me about it. :)

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 23, 2015

(Also, it seems like a case where being backwards incompatible just isn't really necessary.)

fhahn added a commit to fhahn/rust that referenced this issue Oct 23, 2015

@fhahn

This comment has been minimized.

Copy link
Contributor

fhahn commented Oct 23, 2015

Sure that makes perfect senes. @jonas-schievink do you remember where you found the grammar definition which said a bare semicolon should not be allowed? I could not find it.

@jonas-schievink

This comment has been minimized.

Copy link
Member

jonas-schievink commented Oct 23, 2015

bors added a commit that referenced this issue Oct 24, 2015

Auto merge of #29215 - fhahn:issue-28157-bad-semicolon, r=alexcrichton
PR for #28157. At the moment, `rustc` emits a warning when a bare semicolon is encountered (could also be a fail, but I think this is a backwards incompatible change).

Also I am not sure where the best place for a test for that warning would be. Seems run-pass tests do not check warnings.

@bors bors closed this in 1e62bd2 Oct 24, 2015

@fhahn

This comment has been minimized.

Copy link
Contributor

fhahn commented Oct 26, 2015

@jonas-schievink thanks Jonas, I've updated the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.