Error out of invalid Int/Word bit shifts
authorAlec Theriault <alec.theriault@gmail.com>
Fri, 11 Jan 2019 07:44:04 +0000 (23:44 -0800)
committerBen Gamari <ben@well-typed.com>
Wed, 23 Jan 2019 19:07:28 +0000 (14:07 -0500)
commit5341edf3635f2875271acc469570481c52000374
tree98fad051d47888913fa8492170ff537330e5c7eb
parenta90a2aea94b306cf557e74c4c3ed65959d05c20c
Error out of invalid Int/Word bit shifts

Although the Haddock's for `shiftL` and `shiftR` do require the number
of bits to be non-negative, we should still check this before calling
out to primitives (which also have undefined behaviour for negative bit
shifts).

If a user _really_ wants to bypass checks that the number of bits is
sensible, they already have the aptly-named `unsafeShiftL`/`unsafeShiftR`
at their disposal.

See #16111.
compiler/prelude/PrelRules.hs
libraries/base/Data/Bits.hs
libraries/base/GHC/Int.hs
libraries/base/GHC/Word.hs
libraries/base/changelog.md