Fix computation of switch coverage

Closes #3258
This commit is contained in:
LemonBoy
2019-09-23 11:14:36 +02:00
committed by Andrew Kelley
parent 53ae03ebe9
commit db988f42a7
3 changed files with 64 additions and 50 deletions

View File

@@ -2,6 +2,19 @@ const tests = @import("tests.zig");
const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"switch with overlapping case ranges",
\\export fn entry() void {
\\ var q: u8 = 0;
\\ switch (q) {
\\ 1...2 => {},
\\ 0...255 => {},
\\ }
\\}
,
"tmp.zig:5:9: error: duplicate switch value",
);
cases.add(
"attempt to negate a non-integer, non-float or non-vector type",
\\fn foo() anyerror!u32 {