| ... | ... | @@ -1658,13 +1658,17 @@ fn analyzeBodyInner( |
| 1658 | 1658 | const extra = sema.code.extraData(Zir.Inst.BlockComptime, pl_node.payload_index); |
| 1659 | 1659 | const block_body = sema.code.bodySlice(extra.end, extra.data.body_len); |
| 1660 | 1660 | |
| 1661 | | if (block.isComptime()) { |
| 1662 | | // No need for a sub-block; just resolve the other body directly! |
| 1663 | | break :inst try sema.resolveInlineBody(block, block_body, inst); |
| 1664 | | } |
| 1665 | | |
| 1666 | 1661 | var child_block = block.makeSubBlock(); |
| 1667 | 1662 | defer child_block.instructions.deinit(sema.gpa); |
| 1663 | |
| 1664 | // We won't have any merges, but we must ensure this block is properly labeled for |
| 1665 | // any `.restore_err_ret_index_*` instructions. |
| 1666 | var label: Block.Label = .{ |
| 1667 | .zir_block = inst, |
| 1668 | .merges = undefined, |
| 1669 | }; |
| 1670 | child_block.label = &label; |
| 1671 | |
| 1668 | 1672 | child_block.comptime_reason = .{ .reason = .{ |
| 1669 | 1673 | .src = src, |
| 1670 | 1674 | .r = .{ .simple = extra.data.reason }, |
| ... | ... | @@ -1672,7 +1676,9 @@ fn analyzeBodyInner( |
| 1672 | 1676 | |
| 1673 | 1677 | const result = try sema.resolveInlineBody(&child_block, block_body, inst); |
| 1674 | 1678 | |
| 1675 | | if (!try sema.isComptimeKnown(result)) { |
| 1679 | // Only check for the result being comptime-known in the outermost `block_comptime`. |
| 1680 | // That way, AstGen can safely elide redundant `block_comptime` without affecting semantics. |
| 1681 | if (!block.isComptime() and !try sema.isComptimeKnown(result)) { |
| 1676 | 1682 | return sema.failWithNeededComptime(&child_block, src, null); |
| 1677 | 1683 | } |
| 1678 | 1684 | |