# stage2: fixes for error unions, optionals, errors · gitcafe/zig

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

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

Visibility: public

Requested revision: c711c788f0a840f45d0d7423efe2f946b47caafb

Requested commit: c711c788f0a840f45d0d7423efe2f946b47caafb

Commit: c711c788f0a840f45d0d7423efe2f946b47caafb

Tree: 48f57fc696e485937a7b96477657bdd8cdaff534

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: fixes for error unions, optionals, errors

 * `?E` where E is an error set with only one field now lowers the same
   as `bool`.
 * Fix implementation of errUnionErrOffset and errUnionPayloadOffset to
   properly compute the offset of each field. Also name them the same
   as the corresponding LLVM functions and have the same function
   signature, to avoid confusion. This fixes a bug where wasm was
   passing the error union type instead of the payload type.
 * Fix C backend handling of optionals with zero-bit payload types.
 * C backend: separate out airOptionalPayload and airOptionalPayloadPtr
   which reduces branching and cleans up control flow.
 * Make Type.isNoReturn return true for error sets with no fields.
 * Make `?error{}` have only one possible value (null).

```

## Parents

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

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