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

assignment of statement expressions crashes compiler #12089

Closed
jorgeadriano opened this issue Feb 7, 2014 · 1 comment
Closed

assignment of statement expressions crashes compiler #12089

jorgeadriano opened this issue Feb 7, 2014 · 1 comment

Comments

@jorgeadriano
Copy link

According to the manual, "an expression statement is one that evaluates an expression and ignores its result. The type of an expression statement e; is always ()"

However assignments of the form,

let x = {e;}; 

cause the compiler to crash. Likewise with struct field assignments,

S {x: {e;}};

Self-contained example program:

struct S {x:()}

fn main(){

    // crashes the compiler
    let s : S  = S{x: {println!("a");} }; //

    // crashes the compiler
    let x : () = {println!("a");};

    // note the following works
    let y : int = {0};

    // as does
    let z : () = { {println!("a");} ; ()}; 
}
@huonw
Copy link
Member

huonw commented Feb 7, 2014

Closing as a dupe of #11709.

@huonw huonw closed this as completed Feb 7, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…e, r=jonas-schievink

fix: handle raw identifiers in move_module_to_file

Fixes rust-lang#12045

Note that I special case'd mod named `r#mod` as commented in the code. Although it's very unlikely that one would use such name, I included it in this fix for the sake of completeness.
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

No branches or pull requests

2 participants