Skip to content

Parser ICE on syntax error in match arm block #1210

Open
@dafaust

Description

@dafaust

I tried this code:

enum E {
    One,
    Two,
    Other
}

fn foo (x: E) -> i32 {
    let mut y = 0;

    match x {
        E::One => {
            y = 1,
        }
        E::Two => {
            y = 2;
        }
        _ => {}
    }

    return y;
}

fn main () {
    let x = E::One;
    let y = foo (x);
}

I expected to see this happen:

error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
  --> bad.rs:12:18
   |
12 |             y = 1,
   |                  ^ expected one of `.`, `;`, `?`, `}`, or an operator

error: aborting due to previous error

Instead, this happened:

rust1: internal compiler error: Segmentation fault
0x15c4a2f crash_signal
	../../gccrs/gcc/toplev.cc:322
0x7f86dfc0591f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xe9df8a Rust::Parser<Rust::Lexer>::parse_expr_stmt_with_block(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:7276
0xe928dd Rust::Parser<Rust::Lexer>::parse_expr_stmt(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >, Rust::ParseRestrictions)
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:7137
0xe721da Rust::Parser<Rust::Lexer>::parse_expr_with_block(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:7225
0xe48f1c Rust::Parser<Rust::Lexer>::parse_stmt_or_expr_without_block()
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:11730
0xe39973 Rust::Parser<Rust::Lexer>::parse_block_expr(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >, Location)
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:7454
0xe2bed9 Rust::Parser<Rust::Lexer>::parse_function(Rust::AST::Visibility, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:2698
0xe15316 Rust::Parser<Rust::Lexer>::parse_item(bool)
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:1061
0xe082a4 Rust::Parser<Rust::Lexer>::parse_items()
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:403
0xec1225 Rust::Parser<Rust::Lexer>::parse_crate()
	../../gccrs/gcc/rust/parse/rust-parse-impl.h:432
0xeb6cbe Rust::Session::parse_file(char const*)
	../../gccrs/gcc/rust/rust-session-manager.cc:647
0xeb6731 Rust::Session::parse_files(int, char const**)
	../../gccrs/gcc/rust/rust-session-manager.cc:572
0xd95a34 grs_langhook_parse_file
	../../gccrs/gcc/rust/rust-lang.cc:174

Meta

  • What version of Rust GCC were you using, git sha if possible. ca722fe

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions