Skip to content

"task ... ran out of stack" error #6049

Closed
@skinner

Description

@skinner

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions