authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-07 12:59:50-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-07 12:59:50-07:00
loge32898b0dedf1da13798f798d2825113b0be748b
tree405dd461743abac0a500c33e2d2c81fd03a386df
parent18119aae30660c27b088214319cfca396fdf04bf

AstGen: fix switch expressions with all prongs noreturn


1 files changed, 7 insertions(+), 2 deletions(-)

src/AstGen.zig+7-2
......@@ -3356,8 +3356,13 @@ fn switchExpr(
33563356 switch (strat.tag) {
33573357 .break_operand => {
33583358 // Switch expressions return `true` for `nodeMayNeedMemoryLocation` thus
3359 // this is always true.
3360 assert(strat.elide_store_to_block_ptr_instructions);
3359 // `elide_store_to_block_ptr_instructions` will either be true,
3360 // or all prongs are noreturn.
3361 if (!strat.elide_store_to_block_ptr_instructions) {
3362 astgen.extra.appendSliceAssumeCapacity(scalar_cases_payload.items);
3363 astgen.extra.appendSliceAssumeCapacity(multi_cases_payload.items);
3364 return astgen.indexToRef(switch_block);
3365 }
33613366
33623367 // There will necessarily be a store_to_block_ptr for
33633368 // all prongs, except for prongs that ended with a noreturn instruction.