# stage2: fix comptime stores and sentinel-terminated arrays · gitcafe/zig

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

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

Visibility: public

Requested revision: a3104a4a78089f3260c0dd3f4a96012c6d73a63b

Requested commit: a3104a4a78089f3260c0dd3f4a96012c6d73a63b

Commit: a3104a4a78089f3260c0dd3f4a96012c6d73a63b

Tree: 63d73840d9d48d09cd27c3fef5e52f051a2dc4bd

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: fix comptime stores and sentinel-terminated arrays

 * ZIR: the `array_type_sentinel` now has a source node attached to it
   for proper error reporting.
 * Refactor: move `Module.arrayType` to `Type.array`
 * Value: the `bytes` and `array` tags now include the sentinel, if the
   type has one. This simplifies comptime evaluation logic.
 * Sema: fix `zirStructInitEmpty` to properly handle when the type is
   void or a sentinel-terminated array. This handles the syntax `void{}`
   and `[0:X]T{}`.
 * Sema: fix the logic for reporting "cannot store runtime value in
   compile time variable" as well as for emitting a runtime store when a
   pointer value is comptime known but it is a global variable.
 * Sema: implement elemVal for double pointer to array. This can happen
   with this code for example: `var a: *[1]u8 = undefined; _ = a[0];`
 * Sema: Rework the `storePtrVal` function to properly handle nested
   structs and arrays.
   - Also it now handles comptime stores through a bitcasted pointer.
     When the pointer element type and the type according to the Decl
     don't match, the element value is bitcasted before storage.

```

## Parents

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

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