for word in ["mod", "if", "else", "while", "do", "alt", "for", "break",
"cont", "ret", "be", "fail", "type", "resource", "check",
"assert", "claim", "native", "fn", "pure",
- "unsafe", "import", "export", "let", "const",
- "log", "copy", "impl", "iface", "enum"] {
+ "unsafe", "block", "import", "export", "let", "const",
+ "log", "copy", "sendfn", "impl", "iface", "enum"] {
words.insert(word, ());
}
words
_ { /* fallthrough */ }
}
t = parse_ty_fn(proto, p);
+ } else if eat_word(p, "block") {
+ //p.warn("block is deprecated, use fn& or fn");
+ t = parse_ty_fn(ast::proto_block, p);
} else if eat_word(p, "native") {
expect_word(p, "fn");
t = parse_ty_fn(ast::proto_bare, p);
_ { /* fallthrough */ }
}
ret pexpr(parse_fn_expr(p, proto));
+ } else if eat_word(p, "block") {
+ p.warn("block is deprecated, use fn& or fn");
+ ret pexpr(parse_fn_expr(p, ast::proto_block));
} else if eat_word(p, "unchecked") {
ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
} else if eat_word(p, "unsafe") {
p.bump();
ast::proto_block
}
- token::BINOP(token::STAR) {
- p.bump(); // temporary: fn* for any closure
- ast::proto_any
- }
_ {
- ast::proto_bare
+ ast::proto_any
}
}
}
-// error-pattern: mismatched types
-
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
-fn coerce(b: block()) -> fn() {
- fn lol(f: fn(block()) -> fn(), g: block()) -> fn() { ret f(g); }
- fn fn_id(f: fn()) -> fn() { ret f }
+fn coerce(b: fn()) -> native fn() {
+ fn lol(f: native fn(block()) -> native fn(),
+ g: fn()) -> native fn() { ret f(g); }
+ fn fn_id(f: native fn()) -> native fn() { ret f }
ret lol(fn_id, b);
+ //!^ ERROR mismatched types: expected `native fn(fn&()) -> native fn()`
}
-
fn main() {
let i = 8;
- let f = coerce(block () { log(error, i); });
- f(); }
+ let f = coerce({|| log(error, i); });
+ f();
+}