Skip to content

index out of bounds: the len is 1 but the index is 1 #8601

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

Closed
carl-eastlund opened this issue Aug 19, 2013 · 1 comment
Closed

index out of bounds: the len is 1 but the index is 1 #8601

carl-eastlund opened this issue Aug 19, 2013 · 1 comment
Labels
A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@carl-eastlund
Copy link

From this program:

#[deriving (Clone,ToStr)]
enum Type<T> { Constant }

trait Trait<K,V> {
    fn method(&self,Type<(K,V)>) -> ();
}

impl<V:Clone+'static> Trait<u8,V> for () {
    fn method( &self, xs:Type<(u8,V)> ) -> () {
        *self; @xs;
    }
}

fn function<V:Clone+'static>( x:@Trait<V,V> ) -> () {
    x.method(Constant);
}

fn instance<V:Clone+'static>() -> @Trait<u8,V> {
    @() as @Trait<u8,V>
}

fn main () {
    function(instance());
}

...I get this error:

task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1', /Users/cce/git/rust/lang/src/librustc/middle/ty.rs:1509
error: internal compiler error: unexpected failure
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 <unnamed> failed at 'explicit failure', /Users/cce/git/rust/lang/src/librustc/rustc.rs:371
@alexcrichton
Copy link
Member

Slightly smaller version with the same error:

enum Type<T> { Constant }

trait Trait<K,V> {
    fn method(&self,Type<(K,V)>);
}

impl<V:Clone+'static> Trait<u8,V> for () {
    fn method(&self, _: Type<(u8,V)>) {}
}

fn main () {
    let a = @() as @Trait<u8, u8>;
    a.method(Constant);
}

cc @msullivan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants