- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Description
I get a "task .. ran out of stack" error with this program:
use core::hashmap::HashMap;
fn main() {
    let mut map : HashMap<~str, int> = HashMap::new();
    let keys = ~[~"foo", ~"bar", ~"foo"];
    do keys.consume |_, key| {
        let count;
        {
            let count_option = map.find(&key);
            match count_option {
                Some(x) => { count = *x; },
                None => { count = 0; }
            }
        }
        map.insert(key, count + 1);
    }
    for map.each |&key, &count| {
        println(fmt!("%?: %?", key, count));
    }
}
I was originally trying to work around the lack of flow-sensitivity in borrowck, so the code is a little contorted from what would be natural. But I imagine that the "out of stack" error is a separate issue.
rustc is:
rustc 0.6 (ee3789b 2013-04-24 13:33:29 -0700)
host: x86_64-unknown-linux-gnu
running on Fedora 17.
Metadata
Metadata
Assignees
Labels
No labels