From 9cff23dbf9ff3da716a1c4397f9411eba09f6cac Mon Sep 17 00:00:00 2001 From: Isaac Hier Date: Wed, 4 Jul 2018 13:27:10 -0400 Subject: Fix assertion crash on enum switch values --- test/compile_errors.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 7291a48a8f..8bd5480395 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -358,6 +358,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { ".tmp_source.zig:3:14: note: other value is here", ); + + cases.add( + "invalid cast from integral type to enum", + \\const E = enum(usize) { One, Two }; + \\ + \\export fn entry() void { + \\ foo(1); + \\} + \\ + \\fn foo(x: usize) void { + \\ switch (x) { + \\ E.One => {}, + \\ } + \\} + , + ".tmp_source.zig:9:10: error: expected type 'usize', found 'E'" + ); + cases.add( "range operator in switch used on error set", \\export fn entry() void { -- cgit v1.2.3