aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle/trans.rs
diff options
context:
space:
mode:
authorBrian Anderson <[email protected]>2011-01-31 23:06:02 -0500
committerBrian Anderson <[email protected]>2011-02-01 00:08:47 -0500
commit3fedb18c0af0bd9fa5e4973936003c0b57e4d3e8 (patch)
tree69adf95963fda1fedd3338d30f095f73d1c37c77 /src/comp/middle/trans.rs
parentMerge branch 'master' into forgraydon-elseif (diff)
downloadrust-3fedb18c0af0bd9fa5e4973936003c0b57e4d3e8.tar.xz
rust-3fedb18c0af0bd9fa5e4973936003c0b57e4d3e8.zip
Allow the else part of an expr_if to be either expr_if or expr_block
Diffstat (limited to 'src/comp/middle/trans.rs')
-rw-r--r--src/comp/middle/trans.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 8eb614e5..c2b0ae48 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1931,7 +1931,7 @@ fn join_results(@block_ctxt parent_cx,
}
fn trans_if(@block_ctxt cx, @ast.expr cond,
- &ast.block thn, &option.t[ast.block] els) -> result {
+ &ast.block thn, &option.t[@ast.expr] els) -> result {
auto cond_res = trans_expr(cx, cond);
@@ -1942,8 +1942,19 @@ fn trans_if(@block_ctxt cx, @ast.expr cond,
auto else_res = res(else_cx, C_nil());
alt (els) {
- case (some[ast.block](?eblk)) {
- else_res = trans_block(else_cx, eblk);
+ case (some[@ast.expr](?elexpr)) {
+ // FIXME: Shouldn't need to unwrap the block here,
+ // instead just use 'else_res = trans_expr(else_cx, elexpr)',
+ // but either a) trans_expr doesn't handle expr_block
+ // correctly or b) I have no idea what I'm doing...
+ alt (elexpr.node) {
+ case (ast.expr_if(_, _, _, _)) {
+ else_res = trans_expr(else_cx, elexpr);
+ }
+ case (ast.expr_block(?b, _)) {
+ else_res = trans_block(else_cx, b);
+ }
+ }
}
case (_) { /* fall through */ }
}