mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
47 lines
870 B
Zig
47 lines
870 B
Zig
const E = enum { a, b, c };
|
|
var my_e: E = .a;
|
|
|
|
export fn f0() void {
|
|
switch (my_e) {
|
|
.a => {},
|
|
.b => {},
|
|
.x => {},
|
|
.c => {},
|
|
}
|
|
}
|
|
|
|
export fn f1() void {
|
|
switch (my_e) {
|
|
else => {},
|
|
.x, .y => {},
|
|
}
|
|
}
|
|
|
|
export fn f2() void {
|
|
switch (my_e) {
|
|
else => {},
|
|
.a => {},
|
|
.x, .y => {},
|
|
.b => {},
|
|
}
|
|
}
|
|
|
|
export fn f3() void {
|
|
switch (my_e) {
|
|
.a, .b => {},
|
|
.x, .y => {},
|
|
else => {},
|
|
}
|
|
}
|
|
|
|
// error
|
|
//
|
|
// :8:10: error: no field named 'x' in enum 'tmp.E'
|
|
// :1:11: note: enum declared here
|
|
// :16:10: error: no field named 'x' in enum 'tmp.E'
|
|
// :1:11: note: enum declared here
|
|
// :24:10: error: no field named 'x' in enum 'tmp.E'
|
|
// :1:11: note: enum declared here
|
|
// :32:10: error: no field named 'x' in enum 'tmp.E'
|
|
// :1:11: note: enum declared here
|