# Sema: fix analyzeBlockBody logic · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/f0deef1d79db272fa80ef0323b4382ee1936a3e4)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: f0deef1d79db272fa80ef0323b4382ee1936a3e4

Requested commit: f0deef1d79db272fa80ef0323b4382ee1936a3e4

Commit: f0deef1d79db272fa80ef0323b4382ee1936a3e4

Tree: f291eeed6b5d81c4de5aaa6f02030a3fab2bd2a0

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
Sema: fix analyzeBlockBody logic

Previously, when a coercion needed to be inserted into a break
instruction, the `br` AIR instruction would be rewritten so that the
block operand was a sub-block that did the coercion. The problem is that
the sub-block itself was never added to the parent block, resulting in
the `br` instruction operand being a bad reference.

Now, the `br` AIR instruction that needs to have coercion instructions
added is replaced with the sub-block itself with type `noreturn`, and
then the sub-block has the coercion instructions and a new `br`
instruction that breaks from the original block.

LLVM backend needed to be fixed to lower `noreturn` blocks without
emitting an unused LLVM basic block.

```

## Parents

- [d43ebf562d852cb7a7ee983d8084584a53d185ee](https://git.cafe/gitcafe/zig/commit/d43ebf562d852cb7a7ee983d8084584a53d185ee?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/f0deef1d79db272fa80ef0323b4382ee1936a3e4?format=markdown)
