make "native fn" the type for bare functions, remove fn exprs
This commit is contained in:
parent
455f8b0d45
commit
3f3bfeec27
@ -483,7 +483,7 @@ fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) ->
|
||||
|
||||
fn encode_index<T>(ebml_w: ebml::writer, buckets: [@[entry<T>]],
|
||||
write_fn: block(io::writer, T)) {
|
||||
let writer = io::new_writer(ebml_w.writer);
|
||||
let writer = ebml_w.writer;
|
||||
ebml::start_tag(ebml_w, tag_index);
|
||||
let bucket_locs: [uint] = [];
|
||||
ebml::start_tag(ebml_w, tag_index_buckets);
|
||||
|
@ -304,7 +304,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
|
||||
pclose(s);
|
||||
}
|
||||
ast::ty_fn(proto, d) {
|
||||
print_ty_fn(s, proto, d, none, none);
|
||||
print_ty_fn(s, some(proto), d, none, none);
|
||||
}
|
||||
ast::ty_path(path, _) { print_path(s, path, false); }
|
||||
ast::ty_type. { word(s.s, "type"); }
|
||||
@ -485,7 +485,7 @@ fn print_ty_method(s: ps, m: ast::ty_method) {
|
||||
hardbreak_if_not_bol(s);
|
||||
cbox(s, indent_unit);
|
||||
maybe_print_comment(s, m.span.lo);
|
||||
print_ty_fn(s, ast::proto_bare, m.decl, some(m.ident), some(m.tps));
|
||||
print_ty_fn(s, none, m.decl, some(m.ident), some(m.tps));
|
||||
word(s.s, ";");
|
||||
end(s);
|
||||
}
|
||||
@ -1320,11 +1320,11 @@ fn print_mt(s: ps, mt: ast::mt) {
|
||||
print_type(s, mt.ty);
|
||||
}
|
||||
|
||||
fn print_ty_fn(s: ps, proto: ast::proto,
|
||||
fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
|
||||
decl: ast::fn_decl, id: option::t<ast::ident>,
|
||||
tps: option::t<[ast::ty_param]>) {
|
||||
ibox(s, indent_unit);
|
||||
word(s.s, proto_to_str(proto));
|
||||
word(s.s, opt_proto_to_str(opt_proto));
|
||||
alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } }
|
||||
alt tps { some(tps) { print_type_params(s, tps); } _ { } }
|
||||
zerobreak(s.s);
|
||||
@ -1602,6 +1602,13 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
|
||||
ret s;
|
||||
}
|
||||
|
||||
fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {
|
||||
alt opt_p {
|
||||
none. { "fn" }
|
||||
some(p) { proto_to_str(p) }
|
||||
}
|
||||
}
|
||||
|
||||
fn proto_to_str(p: ast::proto) -> str {
|
||||
ret alt p {
|
||||
ast::proto_bare. { "native fn" }
|
||||
|
@ -116,7 +116,7 @@ Returns:
|
||||
|
||||
A handle to the new task
|
||||
*/
|
||||
fn spawn(+f: sendfn()) -> task {
|
||||
fn spawn(+f: fn~()) -> task {
|
||||
spawn_inner(f, none)
|
||||
}
|
||||
|
||||
|
@ -313,24 +313,24 @@ type test_future<T> = {test: test_desc<T>, wait: fn@() -> test_result};
|
||||
fn run_test<T: copy>(test: test_desc<T>,
|
||||
to_task: test_to_task<T>) -> test_future<T> {
|
||||
if test.ignore {
|
||||
ret {test: test, wait: fn () -> test_result { tr_ignored }};
|
||||
ret {test: test, wait: fn@() -> test_result { tr_ignored }};
|
||||
}
|
||||
|
||||
let test_task = to_task(test.fn);
|
||||
ret {test: test,
|
||||
wait:
|
||||
bind fn (test_task: joinable, should_fail: bool) -> test_result {
|
||||
alt task::join(test_task) {
|
||||
task::tr_success. {
|
||||
if should_fail { tr_failed }
|
||||
else { tr_ok }
|
||||
}
|
||||
task::tr_failure. {
|
||||
if should_fail { tr_ok }
|
||||
else { tr_failed }
|
||||
}
|
||||
}
|
||||
}(test_task, test.should_fail)};
|
||||
wait: fn@() -> test_result {
|
||||
alt task::join(test_task) {
|
||||
task::tr_success. {
|
||||
if test.should_fail { tr_failed }
|
||||
else { tr_ok }
|
||||
}
|
||||
task::tr_failure. {
|
||||
if test.should_fail { tr_ok }
|
||||
else { tr_failed }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// We need to run our tests in another task in order to trap test failures.
|
||||
|
@ -45,11 +45,11 @@ mod map_reduce {
|
||||
|
||||
type putter = fn@(str, int);
|
||||
|
||||
type mapper = fn(str, putter);
|
||||
type mapper = fn@(str, putter);
|
||||
|
||||
type getter = fn@() -> option<int>;
|
||||
|
||||
type reducer = fn(str, getter);
|
||||
type reducer = fn@(str, getter);
|
||||
|
||||
tag ctrl_proto {
|
||||
find_reducer(str, chan<chan<reduce_proto>>);
|
||||
|
@ -1,9 +1,8 @@
|
||||
// error-pattern:mismatched types: expected `fn()` but found `fn@()`
|
||||
|
||||
fn f() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Can't produce a bare function by binding
|
||||
let g: fn() = bind f();
|
||||
let g: native fn() = bind f();
|
||||
//!^ ERROR mismatched types: expected `native fn()` but found `fn@()`
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// error-pattern:expected `fn()` but found `fn(++int)`
|
||||
|
||||
fn main() {
|
||||
fn f() { }
|
||||
fn g(i: int) { }
|
||||
let x = f == g;
|
||||
//!^ ERROR expected `native fn()` but found `native fn(++int)`
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
// error-pattern:wrong type in main function: found `fn() -> char`
|
||||
fn main() -> char { }
|
||||
fn main() -> char {
|
||||
//!^ ERROR wrong type in main function: found `native fn() -> char`
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
// error-pattern:wrong type in main function: found `fn(&&{x: int,y: int})`
|
||||
fn main(foo: {x: int, y: int}) { }
|
||||
fn main(foo: {x: int, y: int}) {
|
||||
//!^ ERROR wrong type in main function: found `native fn(&&{x: int,y: int})`
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ fn main() {
|
||||
let cheese = "roquefort";
|
||||
let carrots = @"crunchy";
|
||||
|
||||
fn (tasties: @str, macerate: block(str)) {
|
||||
fn@(tasties: @str, macerate: block(str)) {
|
||||
macerate(*tasties);
|
||||
} (carrots, { |food|
|
||||
let mush = food + cheese;
|
||||
|
@ -1,7 +1,7 @@
|
||||
fn main() {
|
||||
fn echo<T>(c: int, x: native fn(T)) { #error("wee"); }
|
||||
fn echo<T>(c: int, x: fn@(T)) { #error("wee"); }
|
||||
|
||||
let y = bind echo(42, _);
|
||||
|
||||
y(fn(&&i: str) { });
|
||||
y(fn@(&&i: str) { });
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ fn test05_start(&&f: fn~(&&float, &&str) -> pair<float, str>) {
|
||||
assert q.b == "Ho";
|
||||
}
|
||||
|
||||
fn spawn<A: copy, B: copy>(f: fn(fn~(A,B)->pair<A,B>)) {
|
||||
fn spawn<A: copy, B: copy>(f: native fn(fn~(A,B)->pair<A,B>)) {
|
||||
let arg = fn~(a: A, b: B) -> pair<A,B> {
|
||||
ret make_generic_record(a, b);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user