Skip to content

Mismatched type Result instead of Option causes internal compiler error #12499

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
jmmk opened this issue Feb 23, 2014 · 4 comments
Closed

Mismatched type Result instead of Option causes internal compiler error #12499

jmmk opened this issue Feb 23, 2014 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jmmk
Copy link

jmmk commented Feb 23, 2014

rustc 0.10-pre (22d3669 2014-02-22 15:01:58 -0800)
host: x86_64-apple-darwin

credit.rs:20:9: 20:21 error: mismatched types: expected `std::result::Result<~str,std::io::IoError>` but found `std::option::Option<<generic #68>>` (expected enum std::result::Result but found enum std::option::Option)
credit.rs:20         Some(number) => {
                     ^~~~~~~~~~~~
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
Ok(task 'rustc' failed at 'index out of bounds: the len is 0 but the index is 0', /Library/Caches/Homebrew/rust--git/src/librustc/middle/typeck/check/method.rs:452
)
@jmmk
Copy link
Author

jmmk commented Feb 23, 2014

If it matters - the Option was from a BufferedReader call.

@eddyb
Copy link
Member

eddyb commented Mar 2, 2014

This is the shortest testcase I came up with:

fn main() {
    match Ok::<int, ()>(0) {
        Some(x) => {
            x.eq(&0); // ICE
        }
        None => {}
    }
}

Calling a method on the result of pattern matching a type mismatch error is what seems to trigger it.

@jmmk
Copy link
Author

jmmk commented Jul 14, 2014

@eddyb Just tested your example on the latest rust nightly and it no longer gives the error.

@huonw huonw added the I-ICE label Jul 14, 2014
@huonw
Copy link
Member

huonw commented Jul 14, 2014

@huonw huonw closed this as completed Jul 14, 2014
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

No branches or pull requests

3 participants