rust/src/test/compile-fail/issue-2149.rs
2012-07-17 15:46:43 -07:00

16 lines
356 B
Rust

trait vec_monad<A> {
fn bind<B>(f: fn(A) -> ~[B]);
}
impl monad<A> of vec_monad<A> for ~[A] {
fn bind<B>(f: fn(A) -> ~[B]) {
let mut r = fail;
for self.each |elt| { r += f(elt); }
//~^ WARNING unreachable expression
//~^^ ERROR the type of this value must be known
}
}
fn main() {
["hi"].bind({|x| [x] });
}