# stage2: fix incremental compilation Decl deletion logic · gitcafe/zig

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

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

Visibility: public

Requested revision: 4996c2b6a94b042d86b50eb61c9d8d98e63415af

Requested commit: 4996c2b6a94b042d86b50eb61c9d8d98e63415af

Commit: 4996c2b6a94b042d86b50eb61c9d8d98e63415af

Tree: 3857fef9a889a57d20925005579e7ef6784ea2e8

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: fix incremental compilation Decl deletion logic

 * `analyzeContainer` now has an `outdated_decls` set as well as
   `deleted_decls`. Instead of queuing up outdated Decls for re-analysis
   right away, they are added to this new set. When processing the
   `deleted_decls` set, we remove deleted Decls from the
   `outdated_decls` set, to avoid deleted Decl pointers from being in
   the work_queue. Only after processing the deleted decls do we add
   analyze_decl work items to the queue.

 * Module.deletion_set is now an `AutoArrayHashMap` rather than `ArrayList`.
   `declareDeclDependency` will now remove a Decl from it as appropriate.
   When processing the `deletion_set` in `Compilation.performAllTheWork`,
   it now assumes all Decl in the set are to be deleted.

 * Fix crash when handling parse errors. Currently we unload the
   `ast.Tree` if any parse errors occur. Previously the code emitted a
   LazySrcLoc pointing to a token index, but then when we try to resolve
   the token index to a byte offset to create a compile error message,
   the  ast.Tree` would be unloaded. Now we use
   `LazySrcLoc.byte_abs` instead of `token_abs` so the error message can
   be created even with the `ast.Tree` unloaded.

Together, these changes solve a crash that happened with incremental
compilation when Decls were added and removed in some combinations.

```

## Parents

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

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