rustc: If all if branches are _|_, then the entire if is _|_

This commit is contained in:
Brian Anderson 2011-05-21 17:39:28 -04:00
parent c0b4fc1846
commit e24d7ae967
2 changed files with 17 additions and 3 deletions

View File

@ -2144,10 +2144,8 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
if (!ty::type_is_bot(scx.fcx.ccx.tcx, elsopt_t)) {
Pushdown::pushdown_expr(scx, thn_t, els);
if_t = elsopt_t;
} else if (!ty::type_is_bot(scx.fcx.ccx.tcx, thn_t)) {
if_t = thn_t;
} else {
if_t = ty::mk_nil(scx.fcx.ccx.tcx);
if_t = thn_t;
}
}
case (none[@ast::expr]) {

View File

@ -0,0 +1,16 @@
// xfail-stage0
// When all branches of an if expression result in fail, the entire if
// expression results in fail.
fn main() {
auto x = if (true) {
10
} else {
if (true) {
fail
} else {
fail
}
};
}