]> git.lizzy.rs Git - rust.git/commitdiff
Handle alt on a _|_ - typed value
authorTim Chevalier <chevalier@alum.wellesley.edu>
Thu, 4 Aug 2011 23:07:26 +0000 (16:07 -0700)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Thu, 4 Aug 2011 23:07:26 +0000 (16:07 -0700)
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

src/comp/middle/trans_alt.rs
src/test/run-pass/alt-bot-2.rs [new file with mode: 0644]

index 4a1734d3bc1193d17ed9834c6b0d1d3e912e63bc..cdfff0ffe9a908d9603e10189f8a6bc2a485aa22 100644 (file)
@@ -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;
         }
     }
 
diff --git a/src/test/run-pass/alt-bot-2.rs b/src/test/run-pass/alt-bot-2.rs
new file mode 100644 (file)
index 0000000..3183b58
--- /dev/null
@@ -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(); }