Fix PrelRules.caseRules to account for out-of-range tags
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 25 Jul 2018 15:41:16 +0000 (16:41 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 25 Jul 2018 15:41:16 +0000 (16:41 +0100)
commit9897f6783a58265d5eaef5fb06f04320c7737e87
tree0997b497d930f01a3ba93f23a44211a9007fb5e0
parent0f5a63e3d763f18c683f076e0e96396166863f56
Fix PrelRules.caseRules to account for out-of-range tags

As Trac #15436 points out, it is possible to get
   case dataToTag# (x :: T) of
      DEFAULT -> blah1
      -1#     -> blah2
      0       -> blah3

The (-1#) alterantive is unreachable, because dataToTag# returns
tags in the range [0..n-1] where n is the number of data constructors
in type T.

This actually made GHC crash; now we simply discard the unreachable
alterantive.  See Note [Unreachable caseRules alternatives]
in PrelRules
compiler/prelude/PrelRules.hs
compiler/prelude/primops.txt.pp
compiler/simplCore/SimplUtils.hs
testsuite/tests/simplCore/should_run/T15436.hs [new file with mode: 0644]
testsuite/tests/simplCore/should_run/T15436.stdout [new file with mode: 0644]
testsuite/tests/simplCore/should_run/all.T