diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-04-07 12:59:50 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-04-07 12:59:50 -0700 |
| commit | e32898b0dedf1da13798f798d2825113b0be748b (patch) | |
| tree | 405dd461743abac0a500c33e2d2c81fd03a386df /src | |
| parent | 18119aae30660c27b088214319cfca396fdf04bf (diff) | |
| download | zig-e32898b0dedf1da13798f798d2825113b0be748b.tar.gz zig-e32898b0dedf1da13798f798d2825113b0be748b.zip | |
AstGen: fix switch expressions with all prongs noreturn
Diffstat (limited to 'src')
| -rw-r--r-- | src/AstGen.zig | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index d6c2eea5a3..6149169c7f 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -3356,8 +3356,13 @@ fn switchExpr( switch (strat.tag) { .break_operand => { // Switch expressions return `true` for `nodeMayNeedMemoryLocation` thus - // this is always true. - assert(strat.elide_store_to_block_ptr_instructions); + // `elide_store_to_block_ptr_instructions` will either be true, + // or all prongs are noreturn. + if (!strat.elide_store_to_block_ptr_instructions) { + astgen.extra.appendSliceAssumeCapacity(scalar_cases_payload.items); + astgen.extra.appendSliceAssumeCapacity(multi_cases_payload.items); + return astgen.indexToRef(switch_block); + } // There will necessarily be a store_to_block_ptr for // all prongs, except for prongs that ended with a noreturn instruction. |
