add ?? maybe unwrapping binary operator

add null literal
fix number literal / maybe interactions
This commit is contained in:
Andrew Kelley
2016-01-07 03:23:38 -07:00
parent 9b9fd5ad23
commit a3c97081ca
14 changed files with 287 additions and 23 deletions

View File

@@ -710,7 +710,7 @@ pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
add_simple_case("maybe type", R"SOURCE(
use "std.zig";
pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
const x : ?bool = true;
if (const y ?= x) {
@@ -722,6 +722,23 @@ pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
} else {
print_str("x is none\n");
}
const next_x : ?i32 = null;
const z = next_x ?? 1234;
if (z != 1234) {
print_str("BAD\n");
}
const final_x : ?i32 = 13;
const num = final_x ?? unreachable;
if (num != 13) {
print_str("BAD\n");
}
return 0;
}
)SOURCE", "x is true\n");