# translate-c: fix codegen when C source has variables named the same as mangling prefixes · gitcafe/zig

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

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

Visibility: public

Requested revision: bc4d9f3aa93ad58f9cbc75021dc297f29dcf2961

Requested commit: bc4d9f3aa93ad58f9cbc75021dc297f29dcf2961

Commit: bc4d9f3aa93ad58f9cbc75021dc297f29dcf2961

Tree: 3b4a79951526d1e603018144c93e467ef412fc87

Author: Casey Banner

Committer: GitHub

## Message

```
translate-c: fix codegen when C source has variables named the same as mangling prefixes

If the C code had variables that were named the same as the prefixes used
for name mangling, such as "tmp" or "ref", then the codegen would generate
incorrect code in some cases. This was because these aliases were immediately
visible to expressions that actually needed to use the original name.

I introduced the concept of reserving aliases without enabling them. An alias
that isn't enabled isn't visible to expression translation, but is still
reserved so that sub-expressions generate aliases that don't overlap.

Add test cases to cover the cases that would break before this change.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
```

## Parents

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

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