Skip to content

Commit 0a85ea7

Browse files
committed
---
yaml --- r: 945 b: refs/heads/master c: f55f46a h: refs/heads/master i: 943: 79b22de v: v3
1 parent ec5e19d commit 0a85ea7

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
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: 4208352527a9c6a0541d89e2aea063e1e298a90e
2+
refs/heads/master: f55f46af64e545a5845a14e6157211773c24193e

trunk/src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ TEST_XFAILS_SELF := $(filter-out \
545545
$(addprefix test/compile-fail/, \
546546
arg-count-mismatch.rs \
547547
arg-type-mismatch.rs \
548+
while-type-error.rs \
548549
), \
549550
$(wildcard test/*/*.rs test/*/*.rc))
550551

trunk/src/comp/middle/typeck.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,27 @@ fn check_expr(&fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
10731073
ast.ann_type(elsopt_t)));
10741074
}
10751075

1076+
case (ast.expr_while(?cond, ?body, _)) {
1077+
auto cond_0 = check_expr(fcx, cond);
1078+
auto cond_1 = demand_expr(fcx, plain_ty(ty_bool), cond_0);
1079+
auto body_1 = check_block(fcx, body);
1080+
1081+
auto ann = ast.ann_type(plain_ty(ty_nil));
1082+
ret @fold.respan[ast.expr_](expr.span,
1083+
ast.expr_while(cond_1, body_1, ann));
1084+
}
1085+
1086+
case (ast.expr_do_while(?body, ?cond, _)) {
1087+
auto cond_0 = check_expr(fcx, cond);
1088+
auto cond_1 = demand_expr(fcx, plain_ty(ty_bool), cond_0);
1089+
auto body_1 = check_block(fcx, body);
1090+
1091+
auto ann = ast.ann_type(block_ty(body_1));
1092+
ret @fold.respan[ast.expr_](expr.span,
1093+
ast.expr_do_while(body_1, cond_1,
1094+
ann));
1095+
}
1096+
10761097
case (ast.expr_call(?f, ?args, _)) {
10771098
// Check the function.
10781099
auto f_0 = check_expr(fcx, f);

trunk/src/test/run-pass/complex.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// -*- rust -*-
22

33
type t = int;
4+
fn nothing() {}
45
fn putstr(str s) {}
56
fn putint(int i) {
67
let int i = 33;
@@ -15,7 +16,7 @@ fn foo(int x) -> int {
1516
while (y < 10) {
1617
putint(y);
1718
if (y * 3 == 4) {
18-
y = y + 2;
19+
y = y + 2; nothing();
1920
}
2021
}
2122
let t z;

0 commit comments

Comments
 (0)