mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
22 lines
682 B
Zig
22 lines
682 B
Zig
test "deprecated code path" {
|
|
compute(.greedy, false, 42);
|
|
}
|
|
|
|
const Strategy = enum { greedy, expensive, fast };
|
|
fn compute(comptime strat: Strategy, comptime foo: bool, bar: usize) void {
|
|
switch (strat) {
|
|
.greedy => {
|
|
// This combination turned out to be ineffective.
|
|
if (!foo) @deprecated(); // use fast strategy when foo is false
|
|
runGreedy(foo, bar);
|
|
},
|
|
.expensive => runExpensive(foo, bar),
|
|
.fast => runFast(foo, bar),
|
|
}
|
|
}
|
|
|
|
extern fn runGreedy(foo: bool, bar: usize) void;
|
|
extern fn runExpensive(foo: bool, bar: usize) void;
|
|
extern fn runFast(foo: bool, bar: usize) void;
|
|
|
|
// test_error=deprecated
|