# compiler: combine \`@intCast\` safety checks · gitcafe/zig

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

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

Visibility: public

Requested revision: c1a5caa4545264b476951e844818f2abe103f41c

Requested commit: c1a5caa4545264b476951e844818f2abe103f41c

Commit: c1a5caa4545264b476951e844818f2abe103f41c

Tree: fcacbb6cb46d76b9bb31a20a7c2149cb3802b7d7

Author: mlugg

Committer: mlugg

## Message

```
compiler: combine `@intCast` safety checks

`castTruncatedData` was a poorly worded error (all shrinking casts
"truncate bits", it's just that we assume those bits to be zext/sext of
the other bits!), and `negativeToUnsigned` was a pointless distinction
which forced the compiler to emit worse code (since two separate safety
checks were required for casting e.g. 'i32' to 'u16') and wasn't even
implemented correctly. This commit combines those safety panics into one
function, `integerOutOfBounds`. The name maybe isn't perfect, but that's
not hugely important; what matters is the new default message, which is
clearer than the old ones: "integer does not fit in destination type".

```

## Parents

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

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