d917815d81
instead of last statement being expression value closes #629
25 lines
480 B
Zig
25 lines
480 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
const FormValue = union(enum) {
|
|
One: void,
|
|
Two: bool,
|
|
};
|
|
|
|
error Whatever;
|
|
|
|
fn foo(id: u64) -> %FormValue {
|
|
return switch (id) {
|
|
2 => FormValue { .Two = true },
|
|
1 => FormValue { .One = {} },
|
|
else => return error.Whatever,
|
|
};
|
|
}
|
|
|
|
test "switch prong implicit cast" {
|
|
const result = switch (%%foo(2)) {
|
|
FormValue.One => false,
|
|
FormValue.Two => |x| x,
|
|
};
|
|
assert(result);
|
|
}
|