Skip to content

'index out of bounds: the len is 0 but the index is 0' on match { } block #12116

Closed
@ghost

Description

I suspect this is malformed typing and pointer mgmt on my part, but regardless, the compiler throws an error rather then tells me I made one.

This is in an attempt to expand on the linked list from the docs.

error output:

task 'rustc' failed at 'index out of bounds: the len is 0 but the index is 0', /build/rust/src/rust-0.9/src/librustc/middle/check_match.rs:245
error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task '<main>' failed at 'explicit failure', /build/rust/src/rust-0.9/src/librustc/lib.rs:453

Offending code:

enum IntList {
    Cons(int, ~IntList),
    Nil
}

fn tail(source_list: &IntList) -> IntList {
    match source_list {
        &Cons(val, ~ref next_list) => IntList::tail(next_list),
        &Cons(val, ~Nil)           => Cons(val, ~Nil),  //commenting this out allows compilation
        _                          => fail!()
    }
}

uname -a

Linux thinktank 3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014 x86_64 GNU/Linux

rust is at 0.9-2 on this box, with the binary pkg from the archlinux repos (should be vanilla compiled.)

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