Skip to content

"the type of this value must be known in this context" reoccurring #5687

Closed
@lifthrasiir

Description

@lifthrasiir

Regarding #2429, I have observed the same error occurring in the recent incoming (5f13e9c 2013-04-02 13:36:51 -0700):

use core::hashmap::linear::LinearMap;
fn main() {
    let mut map = LinearMap::new();
    let set_default = |k: int, v: int| {
        // N.B. we can't use match here due to the other bug #4666
        let insert =
            match map.find_mut(&k) {
                Some(vs) => { /*let vs: &mut ~[int] = vs;*/ vs.push(v); false }
                None => true
            };
        if insert { map.insert(k, ~[v]); }
    };
    set_default(1, 2);
    set_default(2, 3);
    set_default(1, 4);
    for map.each |&(&k, &v)| { io::println(fmt!("%? -> %?", k, v)); }
}

...resulting in:

t.rs:6:24: 6:26 error: the type of this value must be known in this context
t.rs:6             Some(vs) => vs.push(v),
                               ^~

It compiles (and works) correctly if we uncomment let vs: ... = vs; part.

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