codegen: fix else if expression and maybe unwrap expr

This commit is contained in:
Andrew Kelley
2016-01-08 03:59:37 -07:00
parent e1f498212c
commit 0c84ecd19d
5 changed files with 93 additions and 34 deletions

View File

@@ -936,7 +936,27 @@ pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
}
)SOURCE", "OK\n");
add_simple_case("else if expression", R"SOURCE(
use "std.zig";
pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
if (f(1) == 1) {
print_str("OK\n");
}
return 0;
}
fn f(c: u8) -> u8 {
if (c == 0) {
0
} else if (c == 1) {
1
} else {
2
}
}
)SOURCE", "OK\n");
}
////////////////////////////////////////////////////////////////////////////////////