Skip to content

Commit

Permalink
Handle alt on a _|_ - typed value
Browse files Browse the repository at this point in the history
Return the result of the discriminant from trans_alt,
rather than nil, in the _|_ case. This was breaking the
enclosed test case (alt-bot-2) when optimization was disabled.

Closes #769
  • Loading branch information
catamorphism committed Aug 4, 2011
1 parent 5f03ca4 commit e0985c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/comp/middle/trans_alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &ast::arm[],
ret rslt(cx, cx.build.Unreachable());
}
else {
ret rslt(cx, C_nil());
ret er;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/run-pass/alt-bot-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// n.b. This was only ever failing with optimization disabled.
fn a() -> int { alt ret 1 { 2 { 3 } } }
fn main() { a(); }

0 comments on commit e0985c1

Please sign in to comment.