mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
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.
This commit is contained in:
@@ -7691,12 +7691,12 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\};
|
||||
\\
|
||||
\\export fn entry() void {
|
||||
\\ var y = @as(u3, 3);
|
||||
\\ var y = @as(f32, 3);
|
||||
\\ var x = @intToEnum(Small, y);
|
||||
\\ _ = x;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:10:31: error: expected type 'u2', found 'u3'",
|
||||
"tmp.zig:10:31: error: expected integer type, found 'f32'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("union fields with value assignments",
|
||||
|
||||
Reference in New Issue
Block a user