# compiler: make type resolution lazy · gitcafe/zig

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

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

Visibility: public

Requested revision: d6f61e7d3e5d3d22842d5f98b3f73fa352868783

Requested commit: d6f61e7d3e5d3d22842d5f98b3f73fa352868783

Commit: d6f61e7d3e5d3d22842d5f98b3f73fa352868783

Tree: 9120eab1090df308b7aa912f2ecec97e7bc72911

Author: Matthew Lugg

Committer: Matthew Lugg

## Message

```
compiler: make type resolution lazy

...and rework some of the incremental reference tracking. Almost all
kinds of AnalUnit have one property in common: they might never be
referenced in any update despite conceptually "existing", in which case
we don't want to waste time semantically analyzing them. As of the lazy
type resolution introduced in this commit, the only units to which this
does not apply are `memoized_state` and `@"comptime"`. Previously, I had
a somewhat hacky system in `Zcu` for dealing with this, but I now have a
better understanding of the design incremental compilation is converging
on, so can implement a better solution. By finding a few unused bits
lying around (...or making them), we can represent a single bit of state
indicating whether something's corresponding units have ever been
referenced. This is akin to the units being in `Zcu.outdated`, with the
key difference being that the compiler will *not* attempt to analyze
units which are in this state. Once they are first referenced or
depended on, the flag is set to true and the unit is added to `outdated`
so that it can participate in the normal dependency resolution logic.

```

## Parents

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

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