# stage2: improved union support · gitcafe/zig

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

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

Visibility: public

Requested revision: 8b882747813878a40b63572636a6e86a59a8581e

Requested commit: 8b882747813878a40b63572636a6e86a59a8581e

Commit: 8b882747813878a40b63572636a6e86a59a8581e

Tree: 82bb715d9575a81c7b06d1ff205ee43585a47de1

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: improved union support

 * `Module.Union.getFullyQualifiedName` returns a sentinel-terminated
   slice so that backends that need null-termination do not need an
   additional copy.
 * Module.Union: implement a `getLayout` function which returns
   information about ABI size and alignment so that the LLVM backend can
   properly lower union types into llvm types.
 * Sema: `resolveType` now returns `error.GenericPoison` rather than a
   Type with tag `generic_poison`. Callsites that want to allow that
   need to bypass this higher-level function.
 * Sema: implement coercion of enums and enum literals to unions.
 * Sema: fix comptime mutation of pointers to unions
 * LLVM backend: fully implement proper lowering of union types and
   values according to the union layout, and update the handling of AIR
   instructions that deal with unions to support union layouts.
 * LLVM backend: handle `decl_ref_mut`
   - Maybe this should be unreachable since comptime vars should be
     changed to be non-mutable when they go out of scope, but it's
     harmless for the LLVM backend to support lowering the value.
 * Type: fix `requiresComptime` for optionals, pointers, and some other
   types. This function is still wrong for structs, unions, and enums.

```

## Parents

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

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