# stage2: improve source locations of Decl access · gitcafe/zig

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

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

Visibility: public

Requested revision: b2deaf80279aab1322036e55a9646ecbaaa47f44

Requested commit: b2deaf80279aab1322036e55a9646ecbaaa47f44

Commit: b2deaf80279aab1322036e55a9646ecbaaa47f44

Tree: f950b7d882299bab45a6d5ea8cd213d1850c2bb0

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: improve source locations of Decl access

 * zir.Code: introduce a decls array. This is so that `decl_val` and
   `decl_ref` instructions can refer to a Decl with a u32 and therefore
   they can also store a source location. This is needed for proper
   compile error reporting.
 * astgen uses a hash map to avoid redundantly adding a Decl to the
   decls array.
 * fixed reporting "instruction illegal outside function body" instead
   of the desired message "unable to resolve comptime value".
 * astgen skips emitting dbg_stmt instructions in comptime scopes.
 * astgen has some logic to avoid adding unnecessary type coercion
   instructions for common values.

```

## Parents

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

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