Skip to content

Commit e4392bb

Browse files
committed
---
yaml --- r: 2703 b: refs/heads/master c: 6824f11 h: refs/heads/master i: 2701: a11cc4f 2699: f2f5022 2695: 548c181 2687: ce531ef v: v3
1 parent ffdb4bb commit e4392bb

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
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: 418b4c456703501b18f6774e7708186ae9c1e2c2
2+
refs/heads/master: 6824f119fcaef80e6ac377e887cbe6789e587f77

trunk/src/comp/middle/typeck.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,10 @@ mod Pushdown {
14571457
for (ast::arm arm_0 in arms_0) {
14581458
pushdown_block(scx, expected, arm_0.block);
14591459
auto bty = block_ty(scx.fcx.ccx.tcx, arm_0.block);
1460-
t = Demand::simple(scx, e.span, t, bty);
1460+
// Failing alt arms don't need to have a matching type
1461+
if (!ty::type_is_bot(scx.fcx.ccx.tcx, bty)) {
1462+
t = Demand::simple(scx, e.span, t, bty);
1463+
}
14611464
}
14621465
write::ty_only_fixup(scx, ann.id, t);
14631466
}
@@ -2209,8 +2212,11 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
22092212
check_block(scx, arm.block);
22102213

22112214
auto bty = block_ty(scx.fcx.ccx.tcx, arm.block);
2212-
result_ty = Demand::simple(scx, arm.block.span, result_ty,
2213-
bty);
2215+
// Failing alt arms don't need to have a matching type
2216+
if (!ty::type_is_bot(scx.fcx.ccx.tcx, bty)) {
2217+
result_ty = Demand::simple(scx, arm.block.span,
2218+
result_ty, bty);
2219+
}
22142220
}
22152221

22162222
auto i = 0u;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// xfail-stage0
2+
// error-pattern:explicit failure
3+
4+
fn main() {
5+
auto x = alt(true) {
6+
case (false) {
7+
0
8+
}
9+
case (true) {
10+
fail
11+
}
12+
};
13+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// xfail-stage0
2+
3+
fn test_simple() {
4+
auto r = alt (true) {
5+
case (true) {
6+
true
7+
}
8+
case (false) {
9+
fail
10+
}
11+
};
12+
assert (r == true);
13+
}
14+
15+
fn test_box() {
16+
auto r = alt (true) {
17+
case (true) {
18+
[10]
19+
}
20+
case (false) {
21+
fail
22+
}
23+
};
24+
assert (r.(0) == 10);
25+
}
26+
27+
fn main() {
28+
test_simple();
29+
test_box();
30+
}

0 commit comments

Comments
 (0)