mozilla/rust — Issue #1660: Typestate code doesn't handle const item inside fn
Author: marijnh
Created: 2012-01-25 12:21:32+00:00
State: open

This program results in the stack trace below:

```
fn main() {
const x: int = 1<<2;
}
```

Moving the const outside of the function, or giving it a value of `4` instead of an expr_binop, causes the problem to vanish.

```
rust: upcall fail 'Assertion pps_len(first) == num_vars failed', src/comp/middle/tstate/bitvectors.rs:104
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(_ZN9rust_task4failEv+0x25)[0x7f6446b858c5]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(+0x33e09)[0x7f6446b9ce09]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(upcall_fail+0x39)[0x7f6446b88d39]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate10bitvectors12seq_preconds17_97937e9927a2ba47E+0x191)[0x7f6447306d91]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions19find_pre_post_exprs17_db73a395385e7556E+0x62d)[0x7f64473118dd]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions18find_pre_post_expr17_89e9eeee07b165e6E+0x2f62)[0x7f6447318b32]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions18find_pre_post_item17_70cfd4aba0c11d54E+0x6d9)[0x7f6447310d29]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions18find_pre_post_stmt17_6ad085c248168892E+0x1b23)[0x7f644731d573]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions19find_pre_post_block7do_one_17_4534607c837a419cE+0x51)[0x7f644731e071]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions19find_pre_post_block17_e76626f120f5ee8bE+0x1a7)[0x7f644731d777]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions16find_pre_post_fn17_e76626f120f5ee8bE+0xc1)[0x7f644731e1e1]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate19pre_post_conditions11fn_pre_post17_8dcfb934675bacd3E+0x2e0)[0x7f644731e560]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6syntax5visit10visit_item17_4a9d57d4fad0687dE+0x59c)[0x7f6447348b4c]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(+0x55b2bc)[0x7f64475b32bc]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(+0x51122e)[0x7f644756922e]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6syntax5visit9visit_mod17_705a2e54fcc329d8E+0x16d)[0x7f64473483cd]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(+0x5110da)[0x7f64475690da]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6syntax5visit11visit_crate17_5058911030168246E+0x80)[0x7f6447348070]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle6tstate2ck11check_crate17_6ec411bd243f39c5E+0x6ca)[0x7f64472e853a]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(+0x54c89a)[0x7f64475a489a]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6driver6driver4time17_db2d81ec3c3bac49E+0xe1)[0x7f6447489bd1]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6driver6driver12compile_upto17_1ee9f89b1e401939E+0x2d5b)[0x7f644748eacb]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(+0x55b2bc)[0x7f64475b32bc]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6driver6driver13compile_input17_31b580d616dbafdfE+0x1c9)[0x7f6447491649]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc-4171d83aef249987-0.1.so(+0x55b2bc)[0x7f64475b32bc]
stage1/bin/rustc[0x40756e]
stage1/bin/rustc[0x40d3cc]
stage1/bin/rustc[0x40cecb]
stage1/bin/rustc[0x40c426]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/libcore-14bd852465126fe7-0.1.so(+0x76359)[0x7f6447d51359]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(task_start_wrapper+0x30)[0x7f6446b84af0]
error: internal compiler error unexpected failure
note: The compiler hit an unexpected failure path. This is a bug. Try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: upcall fail 'explicit failure', src/comp/driver/rustc.rs:176
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(_ZN9rust_task4failEv+0x25)[0x7f6446b858c5]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(+0x33e09)[0x7f6446b9ce09]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(upcall_fail+0x39)[0x7f6446b88d39]
stage1/bin/rustc[0x407cdd]
stage1/bin/rustc[0x40d3cc]
stage1/bin/rustc[0x407ed5]
stage1/bin/rustc(_rust_main+0x52)[0x407fb2]
/home/marijn/src/rust/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustrt.so(task_start_wrapper+0x30)[0x7f6446b84af0]
rust: domain main @0x18f2740 root task failed
```