Skip to content
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

ICE with phantom types using default type parameters #11964

Closed
omasanori opened this issue Feb 1, 2014 · 2 comments · Fixed by #11982
Closed

ICE with phantom types using default type parameters #11964

omasanori opened this issue Feb 1, 2014 · 2 comments · Fixed by #11982
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@omasanori
Copy link
Contributor

Code:

#[feature(default_type_params)];

struct Foo<T> { dummy: T }

struct Bar<T, U = Foo<T>> { dummy: T }

fn main() {
    let _a: Bar<int> = Bar { dummy: 1 };
}

Output:

error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: the compiler hit an unexpected failure path. this is a bug
task 'rustc' failed at 'assertion failed: !ty::type_has_params(t)', /var/tmp/portage/dev-lang/rust-9999/work/rust-9999/src/librustc/middle/trans/common.rs:826
@alexcrichton
Copy link
Member

cc @eddyb

@eddyb
Copy link
Member

eddyb commented Feb 1, 2014

Sadly, the issue is not with phantom types, but it seems I forgot to substitute type params in defaults for other type params:

#[feature(default_type_params)];
struct Foo<T>(T);
struct Bar<T, U = Foo<T>>(T, U); 
fn main() {
    let _: Bar<bool> = Bar(true, Foo(false));
}
// error: mismatched types: expected `Bar<bool>` but found `Bar<bool,Foo<bool>>` (expected type parameter but found bool)

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

Successfully merging a pull request may close this issue.

3 participants