zig/test/cases/maybe_return.zig
Andrew Kelley b581da41f8 remove compiler directives
* add `setFnTest`, `setFnVisible`, `setFnStaticEval`,
   `setFnNoInline` builtin functions to replace previous
   directive functionality
 * add `coldcc` and `nakedcc` as keywords which can be used as part
   of a function prototype.
 * `setDebugSafety` builtin can be used to set debug safety features
   at a per block scope level.
 * closes #169
2016-09-28 02:33:32 -04:00

18 lines
359 B
Zig

const assert = @import("std").debug.assert;
fn maybeReturn() {
@setFnTest(this, true);
assert(??foo(1235));
assert(if (const _ ?= foo(null)) false else true);
assert(!??foo(1234));
}
// TODO test static eval maybe return
fn foo(x: ?i32) -> ?bool {
@setFnStaticEval(this, false);
const value = ?return x;
return value > 1234;
}