# wasm: \`union_init\` correctly store the tag · gitcafe/zig

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

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

Visibility: public

Requested revision: 49fddbf4c11d4ea493c1e5b6176052aeacc1ad10

Requested commit: 49fddbf4c11d4ea493c1e5b6176052aeacc1ad10

Commit: 49fddbf4c11d4ea493c1e5b6176052aeacc1ad10

Tree: 57d3e00ec5c6f37196d74d8bf6caef7bc8765408

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: `union_init` correctly store the tag

Previously we would only store the payload, but not the actual tag
that was set. This meant miscompilations where it would incorrectly
return the tag value.

This also adds a tiny optimization for payloads which are not `byRef`
by directly storing them based on offset, rather than first calculating
a pointer to an offset.

```

## Parents

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

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