It is very easy to use the integer extensions that initialize a type with another that cannot always be represented, but then not fully understand that these initializers aren't always "safe", and that when they fail they generate a runtime error, crashing the process.
For example:
let a = Int32(-1)
let b = UInt32(a) // "Fatal error: Negative value is not representable"
And:
let a = UInt64(0xFF00000000000000)
let b = UInt32(a) // "Fatal error: Not enough bits to represent the passed value"
Is there a way to prevent using these initializers at compile time? The sources show these are preconditions and from what I found only -0unchecked disables these, but this sounds like it disables other good things that generally shouldn't be turned off.
Unfortunately I don't think a linter can help since the types need to be fully understood, as these initializers can also be used with imported C types as aliases.
One idea I imagine could be to annotate these functions and provide a compiler flag to prevent using them.