# fix not updating debug info type of optional error sets · gitcafe/zig

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

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

Visibility: public

Requested revision: 34eb9f18acc2370973adcc7be0d010d62300e9a9

Requested commit: 34eb9f18acc2370973adcc7be0d010d62300e9a9

Commit: 34eb9f18acc2370973adcc7be0d010d62300e9a9

Tree: 9701cfe85107331cc84b9ef6ee77c832afbfe013

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
fix not updating debug info type of optional error sets

There's an unfortunate footgun in the current design of error sets.
The debug info type for every error set is the same as the debug info
type of the global error set, which is essentially an enum forward
declaration. The problem is that when we "replace" the forward
declaration with the final value, once we know all the possible errors,
we have to update the pointers of every error set.

So the footgun is that if you ever copy the debug info type of the
global error set, you have to add the address of the pointer to a list
of pointers that need to be updated once we "replace" the forward
declaration. I activated the footgun when I introduced the optimization
that `?anyerror` types are the same size as `anyerror` types (using 0 as
the null value), because I introduced a pointer copy of the global error
set debug info type, but forgot to add it to the list.

I'm sure that there is a better way to code this, which does not have
the footgun, but this commit contains only a fix, not a reworking of the
logic.

closes #1937

```

## Parents

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

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