fix casting integer literal to enum

This commit is contained in:
Andrew Kelley
2017-12-05 18:09:22 -05:00
parent 74cea89fce
commit 63a2f9a8b2
3 changed files with 36 additions and 7 deletions

View File

@@ -2684,4 +2684,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
,
".tmp_source.zig:11:13: error: switch on union which has no attached enum",
".tmp_source.zig:1:17: note: consider 'union(enum)' here");
cases.add("enum in field count range but not matching tag",
\\const Foo = enum(u32) {
\\ A = 10,
\\ B = 11,
\\};
\\export fn entry() {
\\ var x = Foo(0);
\\}
,
".tmp_source.zig:6:16: error: enum 'Foo' has no tag matching integer value 0",
".tmp_source.zig:1:13: note: 'Foo' declared here");
}