diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-08-28 15:48:39 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-08-28 15:48:39 -0400 |
| commit | b65cca37ceb2b4181a4e713c270c546682acea23 (patch) | |
| tree | 784f0d0f331f19405b72c53bfabb9f52622be7df /test/compile_errors.zig | |
| parent | 901b5c1566a497822b98ba9327578839bac3df50 (diff) | |
| download | zig-b65cca37ceb2b4181a4e713c270c546682acea23.tar.gz zig-b65cca37ceb2b4181a4e713c270c546682acea23.zip | |
add test coverage for invalid switch expression parameter
closes #604
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 5405b7b8a8..9979ed666c 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,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; \\export fn entry() void { |
