add test coverage for invalid switch expression parameter

closes #604
master
Andrew Kelley 2018-08-28 15:48:39 -04:00
parent 901b5c1566
commit b65cca37ce
No known key found for this signature in database
GPG Key ID: 4E7CD66038A4D47C
1 changed files with 16 additions and 0 deletions

View File

@ -1,6 +1,22 @@
const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"switch with invalid expression parameter",
\\export fn entry() void {
\\ Test(i32);
\\}
\\fn Test(comptime T: type) void {
\\ const x = switch (T) {
\\ []u8 => |x| 123,
\\ i32 => |x| 456,
\\ else => unreachable,
\\ };
\\}
,
".tmp_source.zig:7:17: error: switch on type 'type' provides no expression parameter",
);
cases.add(
"function protoype with no body",
\\fn foo() void;