Skip to content

ICE: resolve didn't write in variant #15896

Closed
@pnkfelix

Description

@pnkfelix

Here is a test case:

fn main() {
    enum R { REB(()) }
    struct Tau { t: uint }
    enum E { B(R, Tau) }

    let e = B(REB(()), Tau { t: 3 });
    let u = match e {
        B(Tau{t: x}, _) => x,
    };
    println!("u: {}", u);
}

It contains a programmer error: They swapped the order of arguments to the B variant constructor.

It seems like some component gets confused though, and we end up ICE'ing instead of providing a useful error message. (I'm guessing the fact that I am passing a struct into a pattern that is expecting some enum variant is part of the explanation here; perhaps it is being parsed expecting the pattern to be an instance of some (non-existent) struct-variant of the enum being matched?

Transcript:

% rustc --version
rustc 0.12.0-pre (5ddc7b4a252fbebee5f2ac87ed755139816d6823 2014-07-18 13:31:22 +0000)
% rustc /tmp/f.rs
/tmp/f.rs:8:11: 8:20 error: internal compiler error: resolve didn't write in variant
/tmp/f.rs:8         B(Tau{t: x}, _) => x,
                      ^~~~~~~~~
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /Users/fklock/Dev/Mozilla/rust.git/src/libsyntax/diagnostic.rs:115

% 

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions