fix compiler crash switching on global error with no else

This commit is contained in:
Andrew Kelley
2018-02-09 13:49:58 -05:00
parent 1fb308ceee
commit e7bf8f3f04
4 changed files with 38 additions and 19 deletions

View File

@@ -1,6 +1,18 @@
const tests = @import("tests.zig");
pub fn addCases(cases: &tests.CompileErrorContext) void {
cases.add("no else prong on switch on global error set",
\\export fn entry() void {
\\ foo(error.A);
\\}
\\fn foo(a: error) void {
\\ switch (a) {
\\ error.A => {},
\\ }
\\}
,
".tmp_source.zig:5:5: error: else prong required when switching on type 'error'");
cases.add("inferred error set with no returned error",
\\export fn entry() void {
\\ foo() catch unreachable;