add ?? maybe unwrapping binary operator
add null literal fix number literal / maybe interactions
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user