Stage1: Add compile error for an empty switch on a integer

This commit is contained in:
Timon Kruiper
2019-11-20 19:34:20 +01:00
committed by Andrew Kelley
parent e3404e3c78
commit 94299d16d1
2 changed files with 13 additions and 0 deletions

View File

@@ -2,6 +2,16 @@ const tests = @import("tests.zig");
const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"empty switch on an integer",
\\export fn entry() void {
\\ var x: u32 = 0;
\\ switch(x) {}
\\}
,
"tmp.zig:3:5: error: switch must handle all possibilities",
);
cases.add(
"regression test #2980: base type u32 is not type checked properly when assigning a value within a struct",
\\const Foo = struct {