mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Stage1: Add compile error for an empty switch on a integer
This commit is contained in:
parent
e3404e3c78
commit
94299d16d1
@ -40,6 +40,9 @@ void rangeset_sort(RangeSet *rs) {
|
||||
}
|
||||
|
||||
bool rangeset_spans(RangeSet *rs, BigInt *first, BigInt *last) {
|
||||
if (rs->src_range_list.length == 0)
|
||||
return false;
|
||||
|
||||
rangeset_sort(rs);
|
||||
|
||||
const Range *first_range = &rs->src_range_list.at(0).range;
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user