Closed
Description
The follow code fails with
foo.rs:5:14: 5:18 error: the type of this value must be known in this context
foo.rs:5 find({|f| f.id == x}, arr);
^~~~
If I move the +=
statement above the call to find, it typechecks. Maybe this is a fundamental limitation of our typechecker, but it looks like it could be worked around by delaying the error until all constraints in a function have been collected.
fn find<@T>(_f: block(T) -> bool, _v: [T]) {}
fn main() {
let x = 10, arr = [];
find({|f| f.id == x}, arr);
arr += [{id: 20}]; // This assigns a type to arr
}