mirror of
https://github.com/ziglang/zig.git
synced 2025-01-05 18:00:25 +00:00
parent
d5fc826437
commit
763357c9c3
@ -2,6 +2,25 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.addTest(
|
||||
"not an enum type",
|
||||
\\export fn entry() void {
|
||||
\\ var self: Error = undefined;
|
||||
\\ switch (self) {
|
||||
\\ InvalidToken => |x| return x.token,
|
||||
\\ ExpectedVarDeclOrFn => |x| return x.token,
|
||||
\\ }
|
||||
\\}
|
||||
\\const Error = union(enum) {
|
||||
\\ A: InvalidToken,
|
||||
\\ B: ExpectedVarDeclOrFn,
|
||||
\\};
|
||||
\\const InvalidToken = struct {};
|
||||
\\const ExpectedVarDeclOrFn = struct {};
|
||||
,
|
||||
".tmp_source.zig:4:9: error: not an enum type",
|
||||
);
|
||||
|
||||
cases.addTest(
|
||||
"binary OR operator on error sets",
|
||||
\\pub const A = error.A;
|
||||
|
Loading…
Reference in New Issue
Block a user