# Sema: implement comptime variables · gitcafe/zig

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

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

Visibility: public

Requested revision: 6ae0825e7f87fc9b73a4b968964196b0e164f062

Requested commit: 6ae0825e7f87fc9b73a4b968964196b0e164f062

Commit: 6ae0825e7f87fc9b73a4b968964196b0e164f062

Tree: 9c48fd4314fda457e5c54717407f0b15ea3aff8e

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
Sema: implement comptime variables

Sema now properly handles alloc_inferred and alloc_inferred_mut ZIR
instructions inside a comptime execution context. In this case it
creates Decl objects and points to them with the new `decl_ref_mut`
Value Tag. `storePtr` is updated to mutate such Decl types and values.
In this case it destroys the old arena and makes a new one, preventing
memory growth during comptime code execution.

Additionally:

 * Fix `storePtr` to emit a compile error for a pointer comptime-known
   to be undefined.
 * Fix `storePtr` to emit runtime instructions for all the cases that a
   pointer is comptime-known but does not support comptime
   dereferencing, such as `@intToPtr` on a hard-coded address, or an
   extern function.
 * Fix `ret_coerce` not coercing inside inline function call context.

```

## Parents

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

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