remove error to/from int casting syntax; add @errorToInt/@intToError
See #1061
This commit is contained in:
@@ -31,8 +31,8 @@ test "@errorName" {
|
||||
}
|
||||
|
||||
test "error values" {
|
||||
const a = i32(error.err1);
|
||||
const b = i32(error.err2);
|
||||
const a = @errorToInt(error.err1);
|
||||
const b = @errorToInt(error.err2);
|
||||
assert(a != b);
|
||||
}
|
||||
|
||||
@@ -147,14 +147,14 @@ test "syntax: optional operator in front of error union operator" {
|
||||
}
|
||||
|
||||
test "comptime err to int of error set with only 1 possible value" {
|
||||
testErrToIntWithOnePossibleValue(error.A, u32(error.A));
|
||||
comptime testErrToIntWithOnePossibleValue(error.A, u32(error.A));
|
||||
testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A));
|
||||
comptime testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A));
|
||||
}
|
||||
fn testErrToIntWithOnePossibleValue(
|
||||
x: error{A},
|
||||
comptime value: u32,
|
||||
) void {
|
||||
if (u32(x) != value) {
|
||||
if (@errorToInt(x) != value) {
|
||||
@compileError("bad");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user