# stage2: implement basic unions · gitcafe/zig

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

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

Visibility: public

Requested revision: c0aa4a1a42b3e0d312bd274799be67d60a1c0238

Requested commit: c0aa4a1a42b3e0d312bd274799be67d60a1c0238

Commit: c0aa4a1a42b3e0d312bd274799be67d60a1c0238

Tree: 6af32089a5fd3b6f79d7eb8a5fcb26bd0a46c39b

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: implement basic unions

 * AIR instructions struct_field_ptr and related functions now are also
   emitted by the frontend for unions. Backends must inspect the type
   of the pointer operand to lower the instructions correctly.
   - These will be renamed to `agg_field_ptr` (short for "aggregate") in
     the future.
 * Introduce the new `set_union_tag` AIR instruction.
 * Introduce `Module.EnumNumbered` and associated `Type` methods. This
   is for enums which have no decls, but do have the possibility of
   overriding the integer tag type and tag values.
 * Sema: Implement support for union tag types in both the
   auto-generated and explicitly-provided cases, as well as explicitly
   provided enum tag values in union declarations.
 * LLVM backend: implement lowering union types, union field pointer
   instructions, and the new `set_union_tag` instruction.

```

## Parents

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

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