# stage2: make zir.Inst.Ref a non-exhaustive enum · gitcafe/zig

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

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

Visibility: public

Requested revision: 0c601965ab6600fdaf5be3c017176a6871413026

Requested commit: 0c601965ab6600fdaf5be3c017176a6871413026

Commit: 0c601965ab6600fdaf5be3c017176a6871413026

Tree: 12c797047baf1bbc87a89c4b513bc2227b9f177f

Author: Isaac Freund

Committer: Isaac Freund

## Message

```
stage2: make zir.Inst.Ref a non-exhaustive enum

This provides us greatly increased type safety and prevents the common
mistake of using a zir.Inst.Ref where a zir.Inst.Index was expected or
vice-versa. It also increases the ergonomics of using the typed values
which can be directly referenced with a Ref over the previous zir.Const
approach.

The main pain point is casting between a []Ref and []u32, which could be
alleviated in the future with a new std.mem function.

```

## Parents

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

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