Skip to content

ICE during coherence check when impl'ing on the same type twice: "Asked to compute kind of a type variable" #4894

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
bstrie opened this issue Feb 12, 2013 · 3 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@bstrie
Copy link
Contributor

bstrie commented Feb 12, 2013

fn main() {}

trait MyAdd<RHS,Result> {
    pure fn add(&self, rhs: &RHS) -> Result;
}

impl<T: Copy> ~[T] : MyAdd<&[T],~[T]> {
    pure fn add(&self, rhs: & &self/[T]) -> ~[T] {}
}

impl<T: Copy> ~[T] : MyAdd<&[T],~[T]> {
    pure fn add(&self, rhs: & &self/[T]) -> ~[T] {}
}
$ rustc vectest.rs 
error: internal compiler error: Asked to compute kind of a type variable
@Aatch
Copy link
Contributor

Aatch commented Apr 29, 2013

This still happens with updated syntax:

fn main() {}

trait MyAdd<RHS,Result> {
    fn add(&self, rhs: &RHS) -> Result;
}

impl<'self, T: Copy> MyAdd<&'self [T],~[T]> for ~[T] {
    fn add(&self, rhs: & &'self [T]) -> ~[T] {}
}

impl<'self, T: Copy> MyAdd<&'self [T],~[T]> for ~[T] {
    fn add(&self, rhs: & &'self [T]) -> ~[T] {}
}

Though I'm not sure if it should stay on 0.7. This is presumably still an error, right?

@bstrie
Copy link
Contributor Author

bstrie commented Jul 2, 2013

Updated once more, this no longer causes an ICE:

fn main() {}

trait MyAdd<RHS,Result> {
    fn add(&self, rhs: &RHS) -> Result;
}

impl<'self, T: Copy> MyAdd<&'self [T],~[T]> for ~[T] {
    fn add(&self, rhs: & &'self [T]) -> ~[T] { rhs.to_owned() }
}

impl<'self, T: Copy> MyAdd<&'self [T],~[T]> for ~[T] {
    fn add(&self, rhs: & &'self [T]) -> ~[T] { rhs.to_owned() }
}

In fact it compiles and runs fine. Closing this bug, and I'll open another one for the fact that you can impl twice on the same type.

@bstrie bstrie closed this as completed Jul 2, 2013
@bstrie
Copy link
Contributor Author

bstrie commented Jul 2, 2013

Opened #7555 for the double-impl issue.

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 A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants