# stage2: implement \`@panic\` and beginnigs of inferred error sets · gitcafe/zig

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

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

Visibility: public

Requested revision: 13f04e3012b6b2eee141923f9780fce55f7a999d

Requested commit: 13f04e3012b6b2eee141923f9780fce55f7a999d

Commit: 13f04e3012b6b2eee141923f9780fce55f7a999d

Tree: fd8d164d7926d76a1e967b89283322ee6ad88bb0

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: implement `@panic` and beginnigs of inferred error sets

 * ZIR: add two instructions:
   - ret_err_value_code
   - ret_err_value
 * AstGen: add countDefers and utilize it to emit more efficient ZIR for
   return expressions in the presence of defers.
 * AstGen: implement |err| payloads for `errdefer` syntax.
   - There is not an "unused capture" error for it yet.
 * AstGen: `return error.Foo` syntax gets a hot path in return
   expressions, using the new ZIR instructions. This also is part of
   implementing inferred error sets, since we need to tell Sema to add
   an error value to the inferred error set before it gets coerced.
 * Sema: implement `@setCold`.
   - Implement `@setCold` support for C backend.
 * `@panic` and regular safety panics such as `unreachable` now properly
   invoke `std.builtin.panic`.
 * C backend: improve pointer and function value rendering.
 * C linker: fix redundant typedefs.
 * Add Type.error_set_inferred.
 * Fix Value.format for enum_literal, enum_field_index, bytes.
 * Remove the C backend test that checks for identical text

I measured a 14% reduction in Total ZIR Bytes from master branch
for std/os.zig.

```

## Parents

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

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