# wasm: implement \`error_set_has_value\` · gitcafe/zig

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

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

Visibility: public

Requested revision: d4ceb12ae9d409dbd52c1f5c96312a1e6ad7d6bc

Requested commit: d4ceb12ae9d409dbd52c1f5c96312a1e6ad7d6bc

Commit: d4ceb12ae9d409dbd52c1f5c96312a1e6ad7d6bc

Tree: 2431e92ce3e64e0b404a4d7e5a6cb833c298e342

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: implement `error_set_has_value`

This implements the safety check for error casts. The instruction
generates a jump table with 2 possibilities. The operand is used
as an index into the jump table. For cases where the value does
not exist within the error set, it will generate a jump to the
'false' block. For cases where it does exist, it will generate
a jump to the 'true' block. By calculating the highest and lowest
value we can keep the jump table smaller, as it doesn't need to
contain an index into the entire error set.

```

## Parents

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

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