| ... | @@ -5192,26 +5192,6 @@ fn whileExpr( | ... | @@ -5192,26 +5192,6 @@ fn whileExpr( |
| 5192 | try loop_scope.instructions.append(astgen.gpa, cond_block); | 5192 | try loop_scope.instructions.append(astgen.gpa, cond_block); |
| 5193 | try continue_scope.setBlockBody(cond_block); | 5193 | try continue_scope.setBlockBody(cond_block); |
| 5194 | | 5194 | |
| 5195 | // This code could be improved to avoid emitting the continue expr when there | | |
| 5196 | // are no jumps to it. This happens when the last statement of a while body is noreturn | | |
| 5197 | // and there are no `continue` statements. | | |
| 5198 | // Tracking issue: https://github.com/ziglang/zig/issues/9185 | | |
| 5199 | if (while_full.ast.cont_expr != 0) { | | |
| 5200 | _ = try expr(&loop_scope, &loop_scope.base, .{ .ty = .void_type }, while_full.ast.cont_expr); | | |
| 5201 | } | | |
| 5202 | const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; | | |
| 5203 | _ = try loop_scope.addNode(repeat_tag, node); | | |
| 5204 | | | |
| 5205 | try loop_scope.setBlockBody(loop_block); | | |
| 5206 | loop_scope.break_block = loop_block; | | |
| 5207 | loop_scope.continue_block = cond_block; | | |
| 5208 | if (while_full.label_token) |label_token| { | | |
| 5209 | loop_scope.label = @as(?GenZir.Label, GenZir.Label{ | | |
| 5210 | .token = label_token, | | |
| 5211 | .block_inst = loop_block, | | |
| 5212 | }); | | |
| 5213 | } | | |
| 5214 | | | |
| 5215 | var then_scope = parent_gz.makeSubBlock(&continue_scope.base); | 5195 | var then_scope = parent_gz.makeSubBlock(&continue_scope.base); |
| 5216 | defer then_scope.instructions.deinit(astgen.gpa); | 5196 | defer then_scope.instructions.deinit(astgen.gpa); |
| 5217 | | 5197 | |
| ... | @@ -5265,6 +5245,26 @@ fn whileExpr( | ... | @@ -5265,6 +5245,26 @@ fn whileExpr( |
| 5265 | } | 5245 | } |
| 5266 | }; | 5246 | }; |
| 5267 | | 5247 | |
| | 5248 | // This code could be improved to avoid emitting the continue expr when there |
| | 5249 | // are no jumps to it. This happens when the last statement of a while body is noreturn |
| | 5250 | // and there are no `continue` statements. |
| | 5251 | // Tracking issue: https://github.com/ziglang/zig/issues/9185 |
| | 5252 | if (while_full.ast.cont_expr != 0) { |
| | 5253 | _ = try expr(&loop_scope, then_sub_scope, .{ .ty = .void_type }, while_full.ast.cont_expr); |
| | 5254 | } |
| | 5255 | const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; |
| | 5256 | _ = try loop_scope.addNode(repeat_tag, node); |
| | 5257 | |
| | 5258 | try loop_scope.setBlockBody(loop_block); |
| | 5259 | loop_scope.break_block = loop_block; |
| | 5260 | loop_scope.continue_block = cond_block; |
| | 5261 | if (while_full.label_token) |label_token| { |
| | 5262 | loop_scope.label = @as(?GenZir.Label, GenZir.Label{ |
| | 5263 | .token = label_token, |
| | 5264 | .block_inst = loop_block, |
| | 5265 | }); |
| | 5266 | } |
| | 5267 | |
| 5268 | loop_scope.break_count += 1; | 5268 | loop_scope.break_count += 1; |
| 5269 | const then_result = try expr(&then_scope, then_sub_scope, loop_scope.break_result_loc, while_full.ast.then_expr); | 5269 | const then_result = try expr(&then_scope, then_sub_scope, loop_scope.break_result_loc, while_full.ast.then_expr); |
| 5270 | try checkUsed(parent_gz, &then_scope.base, then_sub_scope); | 5270 | try checkUsed(parent_gz, &then_scope.base, then_sub_scope); |