add compile error for missing enumeration value in switch

This commit is contained in:
Andrew Kelley
2016-02-11 16:15:08 -07:00
parent a180168871
commit 08eb19456b
2 changed files with 42 additions and 0 deletions

View File

@@ -1760,6 +1760,23 @@ const float_x = f32(1.0) / f32(0.0);
".tmp_source.zig:3:25: error: division by zero is undefined",
".tmp_source.zig:4:22: error: division by zero is undefined",
".tmp_source.zig:5:26: error: division by zero is undefined");
add_compile_fail_case("missing switch prong", R"SOURCE(
enum Number {
One,
Two,
Three,
Four,
}
fn f(n: Number) -> i32 {
switch (n) {
One => 1,
Two => 2,
Three => 3,
}
}
)SOURCE", 1, ".tmp_source.zig:9:5: error: enumeration value 'Four' not handled in switch");
}
//////////////////////////////////////////////////////////////////////////////