# stage2: fix crash that could happen if \`as\` zir fails · gitcafe/zig

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

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

Visibility: public

Requested revision: 67665286575d406769000b3f3e80d4d03d2cab2b

Requested commit: 67665286575d406769000b3f3e80d4d03d2cab2b

Commit: 67665286575d406769000b3f3e80d4d03d2cab2b

Tree: 7cdd00995419c5ced2b1e558975cceca8d76635c

Author: Mitchell Hashimoto

Committer: Andrew Kelley

## Message

```
stage2: fix crash that could happen if `as` zir fails

Example scenario:

    test {
        const a: i32 = blk: {
            if (false) break :blk 24;
        };
        _ = a;
    }

Prior to this, this would panic the compiler with a source needed error.
This provides the source as `sema.src`. This is not ideal, since the
line it points to is pretty far from the true issue. (One block out)

But, this prevents the compiler from straight up crashing and follows a
pattern used by similar ZIR which don't provide a src loc.

```

## Parents

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

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