mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-07 05:15:02 +00:00
rustc: If all if branches are _|_, then the entire if is _|_
This commit is contained in:
parent
c0b4fc1846
commit
e24d7ae967
@ -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]) {
|
||||
|
16
src/test/run-pass/expr-if-fail-all.rs
Normal file
16
src/test/run-pass/expr-if-fail-all.rs
Normal 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
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user