| ... | ... | @@ -249,48 +249,48 @@ fn intLiteral(str: []const u8) !?i64 { |
| 249 | 249 | return error.T; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | | //test "nested error union function call in optional unwrap" { |
| 253 | | // const S = struct { |
| 254 | | // const Foo = struct { |
| 255 | | // a: i32, |
| 256 | | // }; |
| 257 | | // |
| 258 | | // fn errorable() !i32 { |
| 259 | | // var x: Foo = (try getFoo()) orelse return error.Other; |
| 260 | | // return x.a; |
| 261 | | // } |
| 262 | | // |
| 263 | | // fn errorable2() !i32 { |
| 264 | | // var x: Foo = (try getFoo2()) orelse return error.Other; |
| 265 | | // return x.a; |
| 266 | | // } |
| 267 | | // |
| 268 | | // fn errorable3() !i32 { |
| 269 | | // var x: Foo = (try getFoo3()) orelse return error.Other; |
| 270 | | // return x.a; |
| 271 | | // } |
| 272 | | // |
| 273 | | // fn getFoo() anyerror!?Foo { |
| 274 | | // return Foo{ .a = 1234 }; |
| 275 | | // } |
| 276 | | // |
| 277 | | // fn getFoo2() anyerror!?Foo { |
| 278 | | // return error.Failure; |
| 279 | | // } |
| 280 | | // |
| 281 | | // fn getFoo3() anyerror!?Foo { |
| 282 | | // return null; |
| 283 | | // } |
| 284 | | // }; |
| 285 | | // expect((try S.errorable()) == 1234); |
| 286 | | // expectError(error.Failure, S.errorable2()); |
| 287 | | // expectError(error.Other, S.errorable3()); |
| 288 | | // comptime { |
| 289 | | // expect((try S.errorable()) == 1234); |
| 290 | | // expectError(error.Failure, S.errorable2()); |
| 291 | | // expectError(error.Other, S.errorable3()); |
| 292 | | // } |
| 293 | | //} |
| 252 | test "nested error union function call in optional unwrap" { |
| 253 | const S = struct { |
| 254 | const Foo = struct { |
| 255 | a: i32, |
| 256 | }; |
| 257 | |
| 258 | fn errorable() !i32 { |
| 259 | var x: Foo = (try getFoo()) orelse return error.Other; |
| 260 | return x.a; |
| 261 | } |
| 262 | |
| 263 | fn errorable2() !i32 { |
| 264 | var x: Foo = (try getFoo2()) orelse return error.Other; |
| 265 | return x.a; |
| 266 | } |
| 267 | |
| 268 | fn errorable3() !i32 { |
| 269 | var x: Foo = (try getFoo3()) orelse return error.Other; |
| 270 | return x.a; |
| 271 | } |
| 272 | |
| 273 | fn getFoo() anyerror!?Foo { |
| 274 | return Foo{ .a = 1234 }; |
| 275 | } |
| 276 | |
| 277 | fn getFoo2() anyerror!?Foo { |
| 278 | return error.Failure; |
| 279 | } |
| 280 | |
| 281 | fn getFoo3() anyerror!?Foo { |
| 282 | return null; |
| 283 | } |
| 284 | }; |
| 285 | expect((try S.errorable()) == 1234); |
| 286 | expectError(error.Failure, S.errorable2()); |
| 287 | expectError(error.Other, S.errorable3()); |
| 288 | comptime { |
| 289 | expect((try S.errorable()) == 1234); |
| 290 | expectError(error.Failure, S.errorable2()); |
| 291 | expectError(error.Other, S.errorable3()); |
| 292 | } |
| 293 | } |
| 294 | 294 | |
| 295 | 295 | test "widen cast integer payload of error union function call" { |
| 296 | 296 | const S = struct { |