support switching on error union type

closes #23
This commit is contained in:
Andrew Kelley
2016-04-25 21:51:04 -07:00
parent d1b65c6f46
commit d0378057d1
5 changed files with 143 additions and 15 deletions

View File

@@ -1233,6 +1233,18 @@ fn bad_eql_2(a: EnumWithData, b: EnumWithData) -> bool {
)SOURCE", 2,
".tmp_source.zig:3:7: error: operator not allowed for type '[]u8'",
".tmp_source.zig:10:7: error: operator not allowed for type 'EnumWithData'");
add_compile_fail_case("non-const switch number literal", R"SOURCE(
fn foo() {
const x = switch (bar()) {
1, 2 => 1,
3, 4 => 2,
else => 3,
};
}
#static_eval_enable(false)
fn bar() -> i32 { 2 }
)SOURCE", 1, ".tmp_source.zig:3:15: error: unable to infer expression type");
}
//////////////////////////////////////////////////////////////////////////////