diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-08-23 15:30:57 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-08-23 15:30:57 -0700 |
| commit | bb38931c7146678548f63ae9ef71e534c7598fe3 (patch) | |
| tree | 3169ee6a69165cd9bebfc6676fb8f18d7684f390 /test/behavior/enum.zig | |
| parent | d5ef5da5947d24792933847454c84daf1282b29e (diff) | |
| download | zig-bb38931c7146678548f63ae9ef71e534c7598fe3.tar.gz zig-bb38931c7146678548f63ae9ef71e534c7598fe3.zip | |
stage1: `@intToEnum` implicitly does an `@intCast`
This is a backwards-compatible language change.
Previously, `@intToEnum` coerced its integer operand to the integer tag
type of the destination enum type, often requiring the callsite to
additionally wrap the operand in an `@intCast`. Now, the `@intCast` is
implicit, and any integer operand can be passed to `@intToEnum`.
The same as before, it is illegal behavior to pass any integer which does
not have a corresponding enum tag.
Diffstat (limited to 'test/behavior/enum.zig')
| -rw-r--r-- | test/behavior/enum.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig index dbda9f3238..fd526e1bef 100644 --- a/test/behavior/enum.zig +++ b/test/behavior/enum.zig @@ -203,7 +203,7 @@ test "int to enum" { try testIntToEnumEval(3); } fn testIntToEnumEval(x: i32) !void { - try expect(@intToEnum(IntToEnumNumber, @intCast(u3, x)) == IntToEnumNumber.Three); + try expect(@intToEnum(IntToEnumNumber, x) == IntToEnumNumber.Three); } const IntToEnumNumber = enum { Zero, |
