Skip to content

Attempting to write generic extern fns gives seemingly wrong error message (and ICE if used wrong) #8583

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
MicahChalmer opened this issue Aug 18, 2013 · 1 comment

Comments

@MicahChalmer
Copy link
Contributor

I tried to create a generic extern fn, and accidentally left off the type parameter. That caused an ICE. This code reproduces it:

fn with_type_params<T>() { }

extern fn foo<T>() {
    with_type_params::<T>();
}

fn main() {
    let _a:*u8 = foo;
}

and produces this error from the compiler with RUST_LOG=rustc=1:

task <unnamed> failed at 'assertion failed: !ty::type_has_params(*s)', /build/buildd/rust-nightly-201308162101~680eb71~raring/src/librustc/middle/trans/monomorphize.rs:78
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', /build/buildd/rust-nightly-201308162101~680eb71~raring/src/librustc/rustc.rs:371

I wouldn't expect the code above to actually compile, since the type parameter is missing, but it should show an error about that rather than an ICE.

Trying to fix the problem--changing the bare foo to foo::<int> in main, for instance--produced a normal compiler error: "this item does not take type parameters." That also seems wrong--if extern fns are not allowed to take type parameters, then shouldn't the compiler should complain about it at the definition? If they are allowed, then I should be able to take the address of one with the type parameter filled in. (Indeed, that should be required in order to use them.)

@jdm
Copy link
Contributor

jdm commented Aug 22, 2013

This seems like a duplicate of #3171, but if you could put the testcase in there it would be helpful :)

@jdm jdm closed this as completed Aug 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants