Make Lint check for bad uses of `unsafeCoerce`
|Reported by:||simonpj||Owned by:||qnikst|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Revisions:||Phab:D637|
Description (last modified by simonpj)
I think it would be a great idea for Core Lint to check for uses of unsafeCoerce that don't obey the rules. It won't catch all cases, of course, but it would have caught #9035. Specficially, look for:
- Coercions between lifted and unboxed types
- Coercion between unboxed types of different sizes
- Coercion between unboxed ints and floats.
Would anyone like to make a patch for this? Anything that can be checked by Core Lint, should be checked!
I'm afraid I don't know where to look for the reason for the int/float difficulty. I'd write a tiny function that exhibits the unsafe conversion and look the code it generates.
Wiki design page BadUnsafeCoercions