提交 882bea5b 编写于 作者: N Niko Matsakis

Rename fn*() to fn() as originally planned.

上级 1f0b3d22
......@@ -146,8 +146,8 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
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
......@@ -493,6 +493,9 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
_ { /* 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);
......@@ -799,6 +802,9 @@ fn parse_bottom_expr(p: parser) -> pexpr {
_ { /* 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") {
......@@ -2109,12 +2115,8 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
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
}
}
}
......
......@@ -1643,7 +1643,7 @@ fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {
fn proto_to_str(p: ast::proto) -> str {
ret alt p {
ast::proto_bare { "native fn" }
ast::proto_any { "fn*" }
ast::proto_any { "fn" }
ast::proto_block { "fn&" }
ast::proto_uniq { "fn~" }
ast::proto_box { "fn@" }
......
// error-pattern: mismatched types
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
fn main() {
fn f(f: fn(fn(fn()))) {
fn f(f: native fn(native fn(native fn()))) {
}
fn g(f: fn(block())) {
fn g(f: native fn(fn())) {
}
f(g);
//!^ ERROR mismatched types: expected `native fn(native fn(native fn()))`
}
// 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();
}
// pp-exact
fn from_native_fn(x: native fn()) { }
fn from_closure(x: fn()) { }
fn from_stack_closure(x: fn&()) { }
fn from_box_closure(x: fn@()) { }
fn from_unique_closure(x: fn~()) { }
fn main() { }
fn call_any(f: fn*() -> uint) -> uint {
fn call_any(f: fn() -> uint) -> uint {
ret f();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册