# wasm: Fix switching on errors · gitcafe/zig

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

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

Visibility: public

Requested revision: a9a629f89a1d72130103bd59800e1257af84c97c

Requested commit: a9a629f89a1d72130103bd59800e1257af84c97c

Commit: a9a629f89a1d72130103bd59800e1257af84c97c

Tree: 967ff5eac7b0a8cf355a1c4b525ffbbdc32b1626

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Fix switching on errors

Error sets contain the entire global error set.
Users are often switching on specific errors only present within that operand.
This means that cases are almost always sparse and not contiguous.
For this reason, we will instead emit the default case for error values not present in
that specific operand error set. This is fine as those cases will never be hit,
as prevented by the type system.

By still allowing jump tables for those cases, rather than if-else chains, we save runtime cost
as well as binary size.

```

## Parents

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

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