Closed
Description
I happened to write something akin to the following example, and despite a lot of trying I haven't been able to reduce it further.
struct WithProc {
p: proc():Send -> uint
}
impl WithProc {
fn bind(&self, f: proc(a: uint) -> WithProc) -> WithProc {
WithProc{p: proc() {
let s = f((&self.p)());
(s.p)()
}
}
}
}
fn main() {
let wp = WithProc{p: proc() 42u};
}
Output from $ RUST_BACKTRACE=1 rustc ice.rs
$ RUST_BACKTRACE=1 rustc ice.rs
bug3.rs:11:13: 11:24 error: expected function, found `&proc():Send -> uint`
bug3.rs:11 let s = f((&self.p)());
^~~~~~~~~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/tj/rust-lang/src/librustc/middle/typeck/check/mod.rs:2761
stack backtrace:
1: 0x7f0d4b603e10 - rt::backtrace::imp::write::h0600e49e7586edd8V6s
2: 0x7f0d4b606fb0 - failure::on_fail::h9bc5fe4010689545Axt
3: 0x7f0d4b264c70 - unwind::begin_unwind_inner::h1bff612d0d42c1c14ad
4: 0x7f0d4b2648f0 - unwind::begin_unwind_fmt::h80420168126117c4f8c
5: 0x7f0d4b2648b0 - rust_begin_unwind
6: 0x7f0d4b2ab130 - panicking::panic_fmt::h6cad913ef505beeaaOl
7: 0x7f0d4b2b0520 - panicking::panic_bounds_check::hb972af2dd4164e2aIMl
8: 0x7f0d4a29fca0 - middle::typeck::check::check_argument_types::hc6b5223166fd466ci1l
9: 0x7f0d4a29a280 - middle::typeck::check::check_method_argument_types::h277cc4607e230e6arZl
10: 0x7f0d4a2995f0 - middle::typeck::check::try_overloaded_call::h8527e22f18f506d9Pxl
11: 0x7f0d4a2a1650 - middle::typeck::check::check_expr_with_unifier::h41cf85450ccda412Nzm
12: 0x7f0d4a259dc0 - middle::typeck::check::check_block_with_expected::h1a7aa9ae6c95b879vzo
13: 0x7f0d4a2a1650 - middle::typeck::check::check_expr_with_unifier::h41cf85450ccda412Nzm
14: 0x7f0d4a259dc0 - middle::typeck::check::check_block_with_expected::h1a7aa9ae6c95b879vzo
15: 0x7f0d4a231bb0 - middle::typeck::check::check_fn::h603efde2345d70fce0i
16: 0x7f0d4a209870 - middle::typeck::check::closure::check_boxed_closure::h942380912aeb04cefui
17: 0x7f0d4a2a1650 - middle::typeck::check::check_expr_with_unifier::h41cf85450ccda412Nzm
18: 0x7f0d4a2d5cb0 - middle::typeck::check::check_expr_with_unifier::check_struct_or_variant_fields::hfbb97ac76b662f1a2hn
19: 0x7f0d4a2a1650 - middle::typeck::check::check_expr_with_unifier::h41cf85450ccda412Nzm
20: 0x7f0d4a259dc0 - middle::typeck::check::check_block_with_expected::h1a7aa9ae6c95b879vzo
21: 0x7f0d4a231bb0 - middle::typeck::check::check_fn::h603efde2345d70fce0i
22: 0x7f0d4a2566c0 - middle::typeck::check::check_bare_fn::hed3c02a56486583ejPi
23: 0x7f0d4a25cdd0 - middle::typeck::check::check_method_body::h67d32e52b6f50f9elkj
24: 0x7f0d4a2524b0 - middle::typeck::check::check_item::hccace8bfbc1fe9e5t9i
25: 0x7f0d4a256350 - middle::typeck::check::check_item_types::hb0207cfbfd5f8a6btOi
26: 0x7f0d4a5f9e40 - util::common::time::h13078727531352193134
27: 0x7f0d4a5f9050 - middle::typeck::check_crate::hba58bf0e9d989af1cwM
28: 0x7f0d4bb98790 - driver::driver::phase_3_run_analysis_passes::h44dfe72bb661c00a7eS
29: 0x7f0d4bb8d660 - driver::driver::compile_input::h9daa979f32a8eeffdWR
30: 0x7f0d4bc11bd0 - driver::run_compiler::hdd45593b6ab276aflUT
31: 0x7f0d4bc11ac0 - driver::run::closure.59675
32: 0x7f0d4ba1ed60 - task::TaskBuilder::try_future::closure.38929
33: 0x7f0d4b591d90 - task::TaskBuilder::spawn_internal::closure.24280
34: 0x7f0d4b262730 - task::Task::spawn::closure.6094
35: 0x7f0d4b2bdb80 - rust_try_inner
36: 0x7f0d4b2bdb70 - rust_try
37: 0x7f0d4b262810 - unwind::try::h08311d073b2c3873pZc
38: 0x7f0d4b2625d0 - task::Task::run::h4ef6cc9f1ba34aday6b
39: 0x7f0d4b2621c0 - task::Task::spawn::closure.6070
40: 0x7f0d4b263f70 - thread::thread_start::hfa8b96682bc216aflqc
41: 0x7f0d45fc30c0 - start_thread
42: 0x7f0d4af28f89 - __clone
43: 0x0 - <unknown>
The installed version of rustc
is
$ rustc --version=verbose
rustc 0.13.0-dev (2fcbf90d6 2014-11-21 06:21:48 +0000)
binary: rustc
commit-hash: 2fcbf90d6823000ee9a7fa9c4c214ee6a6041931
commit-date: 2014-11-21 06:21:48 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-dev