# stage2: new zir array_init_sent for sentinel-terminated array inits · gitcafe/zig

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

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

Visibility: public

Requested revision: 85b0a4a8fd8a56c07e0377b02d33753fe205fe41

Requested commit: 85b0a4a8fd8a56c07e0377b02d33753fe205fe41

Commit: 85b0a4a8fd8a56c07e0377b02d33753fe205fe41

Tree: 175a059ce3b60e6da72cc1e3c70b37d0af54a216

Author: Mitchell Hashimoto

Committer: Mitchell Hashimoto

## Message

```
stage2: new zir array_init_sent for sentinel-terminated array inits

This uses a new ZIR inst `array_init_sent` (and a ref equivalent) to
represent array init expressions that terminate in a a sentinel value.

The sentienl value is the last value in the `MultiOp` payload. This
makes it a bit more awkward to deal with (lots of "len - 1") but makes
it so that the payload matches the fact that sentinels appear at the end
of arrays. However, this is not a hill I want to die on so if we want to
change it to index 0, I'm happy to do so.

This makes the following work properly:

    try expect(@TypeOf([_:0]u8{}) == [0:0]u8);

```

## Parents

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

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