diff options
| author | Patrick Walton <[email protected]> | 2010-11-23 17:02:08 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-11-23 17:02:08 -0800 |
| commit | f55f46af64e545a5845a14e6157211773c24193e (patch) | |
| tree | ded516265ba4ae8112bb562a9f6fcb4d5993d3c1 /src/comp | |
| parent | rustc: As an experiment, swap the expected/actual types when checking functio... (diff) | |
| download | rust-f55f46af64e545a5845a14e6157211773c24193e.tar.xz rust-f55f46af64e545a5845a14e6157211773c24193e.zip | |
rustc: Typecheck whiles and do-whiles. Add a workaround to complex.rs pending a solution to the one-armed-if problem.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/typeck.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 6a5351fa..aefb92bc 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1073,6 +1073,27 @@ fn check_expr(&fn_ctxt fcx, @ast.expr expr) -> @ast.expr { ast.ann_type(elsopt_t))); } + case (ast.expr_while(?cond, ?body, _)) { + auto cond_0 = check_expr(fcx, cond); + auto cond_1 = demand_expr(fcx, plain_ty(ty_bool), cond_0); + auto body_1 = check_block(fcx, body); + + auto ann = ast.ann_type(plain_ty(ty_nil)); + ret @fold.respan[ast.expr_](expr.span, + ast.expr_while(cond_1, body_1, ann)); + } + + case (ast.expr_do_while(?body, ?cond, _)) { + auto cond_0 = check_expr(fcx, cond); + auto cond_1 = demand_expr(fcx, plain_ty(ty_bool), cond_0); + auto body_1 = check_block(fcx, body); + + auto ann = ast.ann_type(block_ty(body_1)); + ret @fold.respan[ast.expr_](expr.span, + ast.expr_do_while(body_1, cond_1, + ann)); + } + case (ast.expr_call(?f, ?args, _)) { // Check the function. auto f_0 = check_expr(fcx, f); |