# stage2: more Decl lifetime fixes · gitcafe/zig

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

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

Visibility: public

Requested revision: 71afc3088009944fcd8339ac71e69a0b77a781ab

Requested commit: 71afc3088009944fcd8339ac71e69a0b77a781ab

Commit: 71afc3088009944fcd8339ac71e69a0b77a781ab

Tree: d370c17e3561870b151d402c1ba1b32813bda83d

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: more Decl lifetime fixes

 * File stores `root_decl: Decl` instead of `namespace: *Namespace`.
   This maps more cleanly to the actual ownership, since the `File` does
   own the root decl, but it does not directly own the `Namespace`.
 * `semaFile` completes the creation of the `Decl` even when semantic
   analysis fails. The `analysis` field of the `Decl` will contain the
   results of semantic analysis. This prevents cleaning up of memory
   still referenced by other Decl objects.
 * `semaDecl` sets `Struct.zir_index` of the root struct decl, which
   fixes use of undefined value in case the first update contained a ZIR
   compile error.

```

## Parents

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

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