Skip to content

assignment of statement expressions crashes compiler #12089

Closed
@jorgeadriano

Description

@jorgeadriano

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");} ; ()}; 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions