aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-19 03:50:38 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-19 03:50:38 -0400
commita3ddd0826bd9c799768c0c707de72c21befa742a (patch)
tree685b621eb041c178af40c0044c74f689d8d6af7b /test/compile_errors.zig
parent626b73e8beeaae1cab23f883f877d89d64bbfa39 (diff)
downloadzig-a3ddd0826bd9c799768c0c707de72c21befa742a.tar.gz
zig-a3ddd0826bd9c799768c0c707de72c21befa742a.zip
remove enum to/from int casting syntax; add `@enumToInt`/`@intToEnum`
see #1061
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig24
1 files changed, 4 insertions, 20 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 866b303082..609e3f103f 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3710,22 +3710,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
);
cases.add(
- "explicitly casting enum to non tag type",
- \\const Small = enum(u2) {
- \\ One,
- \\ Two,
- \\ Three,
- \\ Four,
- \\};
- \\
- \\export fn entry() void {
- \\ var x = u3(Small.Two);
- \\}
- ,
- ".tmp_source.zig:9:15: error: enum to integer cast to 'u3' instead of its tag type, 'u2'",
- );
-
- cases.add(
"explicitly casting non tag type to enum",
\\const Small = enum(u2) {
\\ One,
@@ -3736,10 +3720,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\
\\export fn entry() void {
\\ var y = u3(3);
- \\ var x = Small(y);
+ \\ var x = @intToEnum(Small, y);
\\}
,
- ".tmp_source.zig:10:18: error: integer to enum cast from 'u3' instead of its tag type, 'u2'",
+ ".tmp_source.zig:10:31: error: expected type 'u2', found 'u3'",
);
cases.add(
@@ -4020,10 +4004,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ B = 11,
\\};
\\export fn entry() void {
- \\ var x = Foo(0);
+ \\ var x = @intToEnum(Foo, 0);
\\}
,
- ".tmp_source.zig:6:16: error: enum 'Foo' has no tag matching integer value 0",
+ ".tmp_source.zig:6:13: error: enum 'Foo' has no tag matching integer value 0",
".tmp_source.zig:1:13: note: 'Foo' declared here",
);