b581da41f8
* 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
29 lines
477 B
Zig
29 lines
477 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
enum FormValue {
|
|
One,
|
|
Two: bool,
|
|
}
|
|
|
|
error Whatever;
|
|
|
|
fn foo(id: u64) -> %FormValue {
|
|
@setFnStaticEval(this, false);
|
|
|
|
switch (id) {
|
|
2 => FormValue.Two { true },
|
|
1 => FormValue.One,
|
|
else => return error.Whatever,
|
|
}
|
|
}
|
|
|
|
fn switchProngImplicitCast() {
|
|
@setFnTest(this, true);
|
|
|
|
const result = switch (%%foo(2)) {
|
|
One => false,
|
|
Two => |x| x,
|
|
};
|
|
assert(result);
|
|
}
|