This is all of the expected 0.14.0 progress on #21530, which can now be postponed once this commit is merged. This required rewriting the (un)wrap operations since the original implementations were extremely buggy. Also adds an easy way to retrigger Sema OPV bugs so that I don't have to keep updating #22419 all the time.
32 lines
928 B
Zig
32 lines
928 B
Zig
const std = @import("std");
|
|
|
|
const Error = error{InvalidCharacter};
|
|
|
|
const Direction = enum { upside_down };
|
|
|
|
const Barrrr = union(enum) {
|
|
float: f64,
|
|
direction: Direction,
|
|
};
|
|
|
|
fn fooey(bar: std.meta.Tag(Barrrr), args: []const []const u8) !Barrrr {
|
|
return switch (bar) {
|
|
.float => .{ .float = try std.fmt.parseFloat(f64, args[0]) },
|
|
.direction => if (std.mem.eql(u8, args[0], "upside_down"))
|
|
Barrrr{ .direction = .upside_down }
|
|
else
|
|
error.InvalidDirection,
|
|
};
|
|
}
|
|
|
|
pub fn main() Error!void {
|
|
std.debug.print("{}", .{try fooey(.direction, &[_][]const u8{ "one", "two", "three" })});
|
|
}
|
|
|
|
// error
|
|
// backend=stage2
|
|
// target=native
|
|
//
|
|
// :23:29: error: expected type 'error{InvalidCharacter}', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).@"fn".return_type.?).error_union.error_set'
|
|
// :23:29: note: 'error.InvalidDirection' not a member of destination error set
|