# stage2: implement union coercion to its own tag · gitcafe/zig

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

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

Visibility: public

Requested revision: 09e1f37cb6a8e0df4c521f4b76eab07f0c811852

Requested commit: 09e1f37cb6a8e0df4c521f4b76eab07f0c811852

Commit: 09e1f37cb6a8e0df4c521f4b76eab07f0c811852

Tree: cce1b86a1cd273841a660e5438f714cfbaea74a7

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: implement union coercion to its own tag

 * AIR: add `get_union_tag` instruction
   - implement in LLVM backend
 * Sema: implement == and != for union and enum literal
   - Also implement coercion from union to its own tag type
 * Value: implement hashing for union values

The motivating example is this snippet:

    comptime assert(@typeInfo(T) == .Float);

This was the next blocker for stage2 building compiler-rt.
Now it is switch at compile-time on an integer.

```

## Parents

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

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