# incremental: fix adding/removing aggregate fields · gitcafe/zig

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

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

Visibility: public

Requested revision: 7d54c62c8a55240bbe144ab03c78573a344598ce

Requested commit: 7d54c62c8a55240bbe144ab03c78573a344598ce

Commit: 7d54c62c8a55240bbe144ab03c78573a344598ce

Tree: f93383d99f058b4cf1aec8a3088c1c9847f138e0

Author: mlugg

Committer: Matthew Lugg

## Message

```
incremental: fix adding/removing aggregate fields

I don't recall why I put these checks here -- they aren't correct. We
can freely recreate a type even if its fields have changed, because we
are going to re-do all type resolution.

The only conditions for recreations are (a) the ZIR index must not be
lost and (b) the number of captures must be the same. These conditions
are permissible because if either is violated, we can guarantee that
analysis of a valid `zirStructDecl` (etc) will never reference this
type (since the ZIR index has just been tracked, and the captures have
just been created based on the ZIR).

Adds a corresponding test case.

Resolves: #21185

```

## Parents

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

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