| author | |
| committer | |
| log | 48ccf427afa59fbcae969f3edd224b44eef153c9 |
| tree | c499e86431d5680804fd354d1dada6214c2fb1d2 |
| parent | 4299cd4446f00ae68edd0c3b5273c83d38a6a253 |
| signature | Commit is signed but in an unrecognized format. |
3 files changed, 46 insertions(+), 2 deletions(-)
src/ir.cpp+2-2| ... | ... | @@ -4065,7 +4065,7 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4065 | 4065 | result_loc, is_comptime); |
| 4066 | 4066 | |
| 4067 | 4067 | ir_set_cursor_at_end_and_append_block(irb, null_block); |
| 4068 | IrInstruction *null_result = ir_gen_node_extra(irb, op2_node, parent_scope, lval, | |
| 4068 | IrInstruction *null_result = ir_gen_node_extra(irb, op2_node, parent_scope, LValNone, | |
| 4069 | 4069 | &peer_parent->peers.at(0)->base); |
| 4070 | 4070 | if (null_result == irb->codegen->invalid_instruction) |
| 4071 | 4071 | return irb->codegen->invalid_instruction; |
| ... | ... | @@ -7496,7 +7496,7 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 7496 | 7496 | } else { |
| 7497 | 7497 | err_scope = parent_scope; |
| 7498 | 7498 | } |
| 7499 | IrInstruction *err_result = ir_gen_node_extra(irb, op2_node, err_scope, lval, &peer_parent->peers.at(0)->base); | |
| 7499 | IrInstruction *err_result = ir_gen_node_extra(irb, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); | |
| 7500 | 7500 | if (err_result == irb->codegen->invalid_instruction) |
| 7501 | 7501 | return irb->codegen->invalid_instruction; |
| 7502 | 7502 | IrBasicBlock *after_err_block = irb->current_basic_block; |
test/stage1/behavior/error.zig+22| ... | ... | @@ -335,3 +335,25 @@ test "debug info for optional error set" { |
| 335 | 335 | const SomeError = error{Hello}; |
| 336 | 336 | var a_local_variable: ?SomeError = null; |
| 337 | 337 | } |
| 338 | ||
| 339 | test "nested catch" { | |
| 340 | const S = struct { | |
| 341 | fn entry() void { | |
| 342 | expectError(error.Bad, func()); | |
| 343 | } | |
| 344 | fn fail() anyerror!Foo { | |
| 345 | return error.Wrong; | |
| 346 | } | |
| 347 | fn func() anyerror!Foo { | |
| 348 | const x = fail() catch | |
| 349 | fail() catch | |
| 350 | return error.Bad; | |
| 351 | unreachable; | |
| 352 | } | |
| 353 | const Foo = struct { | |
| 354 | field: i32, | |
| 355 | }; | |
| 356 | }; | |
| 357 | S.entry(); | |
| 358 | comptime S.entry(); | |
| 359 | } |
test/stage1/behavior/optional.zig+22| ... | ... | @@ -78,3 +78,25 @@ test "unwrap function call with optional pointer return value" { |
| 78 | 78 | S.entry(); |
| 79 | 79 | comptime S.entry(); |
| 80 | 80 | } |
| 81 | ||
| 82 | test "nested orelse" { | |
| 83 | const S = struct { | |
| 84 | fn entry() void { | |
| 85 | expect(func() == null); | |
| 86 | } | |
| 87 | fn maybe() ?Foo { | |
| 88 | return null; | |
| 89 | } | |
| 90 | fn func() ?Foo { | |
| 91 | const x = maybe() orelse | |
| 92 | maybe() orelse | |
| 93 | return null; | |
| 94 | unreachable; | |
| 95 | } | |
| 96 | const Foo = struct { | |
| 97 | field: i32, | |
| 98 | }; | |
| 99 | }; | |
| 100 | S.entry(); | |
| 101 | comptime S.entry(); | |
| 102 | } |