# AstGen: fix const locals with comptime initializations · gitcafe/zig

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

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

Visibility: public

Requested revision: 5c68afef94b0b80823e033bd6965fcda74e19ebe

Requested commit: 5c68afef94b0b80823e033bd6965fcda74e19ebe

Commit: 5c68afef94b0b80823e033bd6965fcda74e19ebe

Tree: e66fb82c14c731edce688b50150ccc38b585b729

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
AstGen: fix const locals with comptime initializations

`const foo = comptime ...` generated invalid ZIR when the initialization
expression contained an array literal because the
validate_array_init_comptime instruction assumed that the corresponding
alloc instruction was comptime. The solution is to look slightly ahead
and notice that the initialization expression would be comptime-known
and affect the alloc instruction tag accordingly.

```

## Parents

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

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