Skip to content

Commit 4f46c17

Browse files
committed
---
yaml --- r: 4695 b: refs/heads/master c: d68f1a8 h: refs/heads/master i: 4693: 6315699 4691: a85412e 4687: f26e5b2 v: v3
1 parent 7cf5127 commit 4f46c17

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9b50011aaeeb7ad37c83124ac5e989f2c7ff8c8d
2+
refs/heads/master: d68f1a80dc666272a5a28f79b37f8feca0cd15be

trunk/src/comp/middle/typeck.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,13 +2051,23 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
20512051
}
20522052
ast::expr_fn(f) {
20532053
let cx = @{tcx: tcx};
2054-
let convert =
2055-
bind ast_ty_to_ty(cx.tcx, bind collect::getter(cx, _), _);
2056-
let ty_of_arg = bind collect::ty_of_arg(cx, _);
2054+
let convert = bind ast_ty_to_ty_crate_tyvar(fcx, _);
2055+
let ty_of_arg = lambda(a: &ast::arg) -> ty::arg {
2056+
let ty_mode = ast_mode_to_mode(a.mode);
2057+
let tt = ast_ty_to_ty_crate_tyvar(fcx, a.ty);
2058+
ret {mode: ty_mode, ty: tt};
2059+
};
20572060
let fty =
20582061
collect::ty_of_fn_decl(cx, convert, ty_of_arg, f.decl, f.proto,
20592062
~[], none).ty;
20602063
write::ty_only_fixup(fcx, id, fty);
2064+
2065+
// Unify the type of the function with the expected type before we
2066+
// typecheck the body so that we have more information about the
2067+
// argument types in the body. This is needed to make binops and
2068+
// record projection work on type inferred arguments.
2069+
unify(fcx, expr.span, expected, fty);
2070+
20612071
check_fn(fcx.ccx, f, id, some(fcx));
20622072
}
20632073
ast::expr_block(b) {
@@ -2611,7 +2621,7 @@ fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
26112621
let gather_result = gather_locals(ccx, f, id, old_fcx);
26122622
let fixups: [ast::node_id] = ~[];
26132623
let fcx: @fn_ctxt =
2614-
@{ret_ty: ast_ty_to_ty_crate(ccx, decl.output),
2624+
@{ret_ty: ty::ty_fn_ret(ccx.tcx, ty::node_id_to_type(ccx.tcx, id)),
26152625
purity: decl.purity,
26162626
proto: f.proto,
26172627
var_bindings: gather_result.var_bindings,

0 commit comments

Comments
 (0)