Skip to content

Commit 8d5e6aa

Browse files
committed
---
yaml --- r: 1410 b: refs/heads/master c: 01c2761 h: refs/heads/master v: v3
1 parent 70105b2 commit 8d5e6aa

File tree

2 files changed

+30
-37
lines changed

2 files changed

+30
-37
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: b389611ce772d65ed135d6e52fecb9ca2238e902
2+
refs/heads/master: 01c2761769ab93682afec9101b4896a7253b5251

trunk/src/comp/middle/typeck.rs

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,47 +1702,40 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
17021702
}
17031703

17041704
case (ast.expr_bind(?f, ?args, _)) {
1705-
auto f_0 = check_expr(fcx, f);
1706-
auto t_0 = expr_ty(f_0);
1707-
1708-
if (!ty.is_fn_ty(t_0)) {
1709-
fcx.ccx.sess.span_err(f_0.span,
1710-
"mismatched types: bind callee has " +
1711-
"non-function type: " +
1712-
ty_to_str(t_0));
1713-
}
1714-
1715-
let ast.proto proto = ty.ty_fn_proto(t_0);
1716-
let vec[arg] arg_tys_0 = ty.ty_fn_args(t_0);
1717-
let @ty.t rt_0 = ty.ty_fn_ret(t_0);
1718-
let vec[option.t[@ast.expr]] args_1 = vec();
1719-
1720-
let uint i = 0u;
1721-
1722-
let vec[arg] residual_args = vec();
1723-
for (option.t[@ast.expr] a in args) {
1724-
alt (a) {
1725-
case (none[@ast.expr]) {
1726-
append[arg](residual_args,
1727-
arg_tys_0.(i));
1728-
append[option.t[@ast.expr]](args_1,
1729-
none[@ast.expr]);
1730-
}
1731-
case (some[@ast.expr](?sa)) {
1732-
auto arg_1 = check_expr(fcx, sa);
1733-
auto arg_t = expr_ty(arg_1);
1734-
demand_expr(fcx, arg_tys_0.(i).ty, arg_1);
1735-
append[option.t[@ast.expr]](args_1,
1736-
some[@ast.expr](arg_1));
1705+
// Call the generic checker.
1706+
auto result = check_call_or_bind(fcx, f, args);
1707+
1708+
// Pull the argument and return types out.
1709+
auto proto_1 = ast.proto_fn; // FIXME: typestate botch
1710+
let vec[ty.arg] arg_tys_1 = vec();
1711+
auto rt_1 = plain_ty(ty.ty_nil); // FIXME: typestate botch
1712+
alt (expr_ty(result._0).struct) {
1713+
case (ty.ty_fn(?proto, ?arg_tys, ?rt)) {
1714+
proto_1 = proto;
1715+
rt_1 = rt;
1716+
1717+
// For each blank argument, add the type of that argument
1718+
// to the resulting function type.
1719+
auto i = 0u;
1720+
while (i < _vec.len[option.t[@ast.expr]](args)) {
1721+
alt (args.(i)) {
1722+
case (some[@ast.expr](_)) { /* no-op */ }
1723+
case (none[@ast.expr]) {
1724+
arg_tys_1 += vec(arg_tys.(i));
1725+
}
1726+
}
1727+
i += 1u;
17371728
}
17381729
}
1739-
i += 1u;
1730+
case (_) {
1731+
log "LHS of bind expr didn't have a function type?!";
1732+
fail;
1733+
}
17401734
}
17411735

1742-
let @ty.t t_1 = plain_ty(ty.ty_fn(proto, residual_args, rt_0));
1743-
1736+
auto t_1 = plain_ty(ty.ty_fn(proto_1, arg_tys_1, rt_1));
17441737
ret @fold.respan[ast.expr_](expr.span,
1745-
ast.expr_bind(f_0, args_1,
1738+
ast.expr_bind(result._0, result._1,
17461739
ast.ann_type(t_1)));
17471740
}
17481741

0 commit comments

Comments
 (0)