aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-03-24 18:51:24 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-03-24 18:51:24 -0400
commit3306e43984a8b17472ecc4b13a2f2815d6630eef (patch)
tree02a0a482a9887c5d439d0e2ec3e442da58a3f89c /test
parentda9d8a6ecfb0428ce3d6575905f96fa1661c9b80 (diff)
downloadzig-3306e43984a8b17472ecc4b13a2f2815d6630eef.tar.gz
zig-3306e43984a8b17472ecc4b13a2f2815d6630eef.zip
add compile error test for invalid enum literal implicit cast
See #683
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 623e1e9ccc..a193095b0f 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3,6 +3,20 @@ const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "cast enum literal to enum but it doesn't match",
+ \\const Foo = enum {
+ \\ a,
+ \\ b,
+ \\};
+ \\export fn entry() void {
+ \\ const x: Foo = .c;
+ \\}
+ ,
+ "tmp.zig:6:20: error: enum 'Foo' has no field named 'c'",
+ "tmp.zig:1:13: note: 'Foo' declared here",
+ );
+
+ cases.add(
"discarding error value",
\\export fn entry() void {
\\ _ = foo();