@@ -53,7 +53,7 @@ test "explicit cast from integer to error type" {
53
53
testCastIntToErr (error .ItBroke );
54
54
comptime testCastIntToErr (error .ItBroke );
55
55
}
56
- fn testCastIntToErr (err : error ) void {
56
+ fn testCastIntToErr (err : anyerror ) void {
57
57
const x = @errorToInt (err );
58
58
const y = @intToError (x );
59
59
assert (error .ItBroke == y );
@@ -80,7 +80,7 @@ fn testPeerResolveArrayConstSlice(b: bool) void {
80
80
assert (mem .eql (u8 , value2 , "zz" ));
81
81
}
82
82
83
- test "implicitly cast from T to error !?T" {
83
+ test "implicitly cast from T to anyerror !?T" {
84
84
castToOptionalTypeError (1 );
85
85
comptime castToOptionalTypeError (1 );
86
86
}
@@ -89,36 +89,36 @@ const A = struct {
89
89
};
90
90
fn castToOptionalTypeError (z : i32 ) void {
91
91
const x = i32 (1 );
92
- const y : error ! ? i32 = x ;
92
+ const y : anyerror ! ? i32 = x ;
93
93
assert ((try y ).? == 1 );
94
94
95
95
const f = z ;
96
- const g : error ! ? i32 = f ;
96
+ const g : anyerror ! ? i32 = f ;
97
97
98
98
const a = A { .a = z };
99
- const b : error ! ? A = a ;
99
+ const b : anyerror ! ? A = a ;
100
100
assert ((b catch unreachable ).? .a == 1 );
101
101
}
102
102
103
- test "implicitly cast from int to error !?T" {
103
+ test "implicitly cast from int to anyerror !?T" {
104
104
implicitIntLitToOptional ();
105
105
comptime implicitIntLitToOptional ();
106
106
}
107
107
fn implicitIntLitToOptional () void {
108
108
const f : ? i32 = 1 ;
109
- const g : error ! ? i32 = 1 ;
109
+ const g : anyerror ! ? i32 = 1 ;
110
110
}
111
111
112
- test "return null from fn() error !?&T" {
112
+ test "return null from fn() anyerror !?&T" {
113
113
const a = returnNullFromOptionalTypeErrorRef ();
114
114
const b = returnNullLitFromOptionalTypeErrorRef ();
115
115
assert ((try a ) == null and (try b ) == null );
116
116
}
117
- fn returnNullFromOptionalTypeErrorRef () error ! ? * A {
117
+ fn returnNullFromOptionalTypeErrorRef () anyerror ! ? * A {
118
118
const a : ? * A = null ;
119
119
return a ;
120
120
}
121
- fn returnNullLitFromOptionalTypeErrorRef () error ! ? * A {
121
+ fn returnNullLitFromOptionalTypeErrorRef () anyerror ! ? * A {
122
122
return null ;
123
123
}
124
124
@@ -163,7 +163,7 @@ fn castToOptionalSlice() ?[]const u8 {
163
163
return "hi" ;
164
164
}
165
165
166
- test "implicitly cast from [0]T to error ![]T" {
166
+ test "implicitly cast from [0]T to anyerror ![]T" {
167
167
testCastZeroArrayToErrSliceMut ();
168
168
comptime testCastZeroArrayToErrSliceMut ();
169
169
}
@@ -172,11 +172,11 @@ fn testCastZeroArrayToErrSliceMut() void {
172
172
assert ((gimmeErrOrSlice () catch unreachable ).len == 0 );
173
173
}
174
174
175
- fn gimmeErrOrSlice () error ! []u8 {
175
+ fn gimmeErrOrSlice () anyerror ! []u8 {
176
176
return []u8 {};
177
177
}
178
178
179
- test "peer type resolution: [0]u8, []const u8, and error ![]u8" {
179
+ test "peer type resolution: [0]u8, []const u8, and anyerror ![]u8" {
180
180
{
181
181
var data = "hi" ;
182
182
const slice = data [0.. ];
@@ -190,7 +190,7 @@ test "peer type resolution: [0]u8, []const u8, and error![]u8" {
190
190
assert ((try peerTypeEmptyArrayAndSliceAndError (false , slice )).len == 1 );
191
191
}
192
192
}
193
- fn peerTypeEmptyArrayAndSliceAndError (a : bool , slice : []u8 ) error ! []u8 {
193
+ fn peerTypeEmptyArrayAndSliceAndError (a : bool , slice : []u8 ) anyerror ! []u8 {
194
194
if (a ) {
195
195
return []u8 {};
196
196
}
@@ -236,7 +236,7 @@ test "peer type resolution: error and [N]T" {
236
236
// else => error.BadValue,
237
237
// };
238
238
//}
239
- fn testPeerErrorAndArray2 (x : u8 ) error ! []const u8 {
239
+ fn testPeerErrorAndArray2 (x : u8 ) anyerror ! []const u8 {
240
240
return switch (x ) {
241
241
0x00 = > "OK" ,
242
242
0x01 = > "OKK" ,
0 commit comments