Don't allow bind to produce bare functions

Issue #1022
This commit is contained in:
Brian Anderson 2011-10-10 13:50:13 -07:00
parent b277039325
commit 5b0f79b75a
2 changed files with 21 additions and 1 deletions

View File

@ -2116,7 +2116,18 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
}
i += 1u;
}
let ft = ty::mk_fn(tcx, proto, out_args, rt, cf, constrs);
// Determine what fn prototype results from binding
fn lower_bound_proto(proto: ast::proto) -> ast::proto {
// FIXME: This is right for bare fns, possibly not others
alt proto {
ast::proto_bare. { ast::proto_fn }
_ { proto }
}
}
let ft = ty::mk_fn(tcx, lower_bound_proto(proto),
out_args, rt, cf, constrs);
write::ty_only_fixup(fcx, id, ft);
}
ast::expr_call(f, args) {

View File

@ -0,0 +1,9 @@
// 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();
}