# stage2: AstGen improvements · gitcafe/zig

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

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

Visibility: public

Requested revision: 01b4bf34ea4f37d8b778bb2413ac1fc445f8bead

Requested commit: 01b4bf34ea4f37d8b778bb2413ac1fc445f8bead

Commit: 01b4bf34ea4f37d8b778bb2413ac1fc445f8bead

Tree: 6075a5f6e35448ab1899b34a559d5c1ce9e27bd2

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: AstGen improvements

 * AstGen: represent compile errors in ZIR rather than returning
   `error.AnalysisFail`.
 * ZIR: remove decl_ref and decl_val instructions. These are replaced by
   `decl_ref_named` and `decl_val_named`, respectively, which will
   probably get renamed in the future to the instructions that were just
   deleted.
 * AstGen: implement `@This()`, `@fence()`, `@returnAddress()`, and
   `@src()`.
 * AstGen: struct_decl improved to support fields_len=0 but have decls.
 * AstGen: fix missing null bytes after compile error messages.
 * SrcLoc: no longer depend on `Decl`. Instead have an explicit field
   `parent_decl_node` which is an absolute AST Node index.
 * Module: `failed_files` table can have null value, in which case the
   key, which is a `*Scope.File`, will have ZIR errors in it.
 * ZIR: implement text rendering of struct decls.
 * CLI: introduce debug_usage and `zig astgen` command which is enabled
   when the compiler is built in debug mode.

```

## Parents

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

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