Skip to content

Commit fcc458d

Browse files
committed
Fix typechecking when spawning something type inferred.
Of course, we still don't *translate* it. Closes #757.
1 parent 2284223 commit fcc458d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/comp/middle/typeck.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,8 +2062,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool {
20622062
ty::mk_fn(fcx.ccx.tcx, proto_1, arg_tys_1, rt_1, cf, constrs);
20632063
}
20642064
_ {
2065-
log_err "LHS of bind expr didn't have a function type?!";
2066-
fail;
2065+
fail "LHS of bind expr didn't have a function type?!";
20672066
}
20682067
}
20692068
write::ty_only_fixup(fcx, id, t_1);
@@ -2087,8 +2086,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool {
20872086
}
20882087
ty::ty_native_fn(_, _, rt) { rt_1 = rt; }
20892088
_ {
2090-
log_err "LHS of call expr didn't have a function type?!";
2091-
fail;
2089+
fail "LHS of call expr didn't have a function type?!";
20922090
}
20932091
}
20942092
write::ty_only_fixup(fcx, id, rt_1);
@@ -2114,7 +2112,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool {
21142112
}
21152113
none. {
21162114
fcx.ccx.tcx.sess.bug("didn't find " + int::str(did.node) +
2117-
" in type cache");
2115+
" in type cache");
21182116
}
21192117
}
21202118
}
@@ -2124,8 +2122,7 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool {
21242122
none. {
21252123
// Shouldn't happen.
21262124
fcx.ccx.tcx.sess.span_err(expr.span,
2127-
"self-call in non-object \
2128-
context");
2125+
"self-call in non-object context");
21292126
}
21302127
}
21312128

@@ -2151,7 +2148,12 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool {
21512148
ast::expr_spawn(_, _, f, args) {
21522149
bot = check_call(fcx, expr.span, f, args, kind_spawn);
21532150
let fty = expr_ty(fcx.ccx.tcx, f);
2154-
let ret_ty = ty::ret_ty_of_fn_ty(fcx.ccx.tcx, fty);
2151+
let ret_ty = alt structure_of(fcx, expr.span, fty) {
2152+
ty::ty_fn(_, _, rt, _, _) { rt }
2153+
ty::ty_native_fn(_, _, rt) { rt }
2154+
_ { fail "LHS of spawn expr didn't have a function type?!" }
2155+
};
2156+
21552157
demand::simple(fcx, f.span, ty::mk_nil(fcx.ccx.tcx), ret_ty);
21562158

21572159
// make sure they aren't spawning a function with type params

0 commit comments

Comments
 (0)