authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-28 15:48:39-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-28 15:48:39-04:00
logb65cca37ceb2b4181a4e713c270c546682acea23
tree784f0d0f331f19405b72c53bfabb9f52622be7df
parent901b5c1566a497822b98ba9327578839bac3df50
signaturelock-open Commit is signed but in an unrecognized format.

add test coverage for invalid switch expression parameter

closes #604

1 files changed, 16 insertions(+), 0 deletions(-)

test/compile_errors.zig+16
......@@ -1,6 +1,22 @@
11const tests = @import("tests.zig");
22
33pub fn addCases(cases: *tests.CompileErrorContext) void {
4 cases.add(
5 "switch with invalid expression parameter",
6 \\export fn entry() void {
7 \\ Test(i32);
8 \\}
9 \\fn Test(comptime T: type) void {
10 \\ const x = switch (T) {
11 \\ []u8 => |x| 123,
12 \\ i32 => |x| 456,
13 \\ else => unreachable,
14 \\ };
15 \\}
16 ,
17 ".tmp_source.zig:7:17: error: switch on type 'type' provides no expression parameter",
18 );
19
420 cases.add(
521 "function protoype with no body",
622 \\fn foo() void;