Commit b65cca37ce

Andrew Kelley <superjoe30@gmail.com>
2018-08-28 21:48:39
add test coverage for invalid switch expression parameter
closes #604
1 parent 901b5c1
Changed files (1)
test/compile_errors.zig
@@ -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;