# stage2: fix switch validation of handling all enum values · gitcafe/zig

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

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

Visibility: public

Requested revision: e730172e47749db8a9d3be5949231bde95343b39

Requested commit: e730172e47749db8a9d3be5949231bde95343b39

Commit: e730172e47749db8a9d3be5949231bde95343b39

Tree: d77ee85e8f3c99a6a13979a22e8650063677b75a

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: fix switch validation of handling all enum values

There were several problems, all fixed:
 * AstGen was storing field names as references to the original
   source code bytes. However, that data would be destroyed when the
   source file is updated. Now, it correctly stores the field names in
   the Decl arena for the enum. The same fix applies to error set field
   names.
 * Sema was missing a memset inside `analyzeSwitch`, leaving the "seen
   enum fields" array with undefined memory. Now that they are all
   properly set to null, the validation works.
 * Moved the "enum declared here" note to the end. It looked weird
   interrupting the notes for which enum values were missing.

```

## Parents

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

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