[commit: ghc] ghc-8.6: Fix PrelRules.caseRules to account for out-of-range tags (851f334)

git at git.haskell.org git at git.haskell.org
Tue Jul 31 20:34:37 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/851f3341953587d9fd2e471994b37ad81f132b1a/ghc

>---------------------------------------------------------------

commit 851f3341953587d9fd2e471994b37ad81f132b1a
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Jul 25 16:41:16 2018 +0100

    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
    
    (cherry picked from commit 9897f6783a58265d5eaef5fb06f04320c7737e87)


>---------------------------------------------------------------

851f3341953587d9fd2e471994b37ad81f132b1a
 compiler/prelude/PrelRules.hs                      | 64 +++++++++++++++-------
 compiler/prelude/primops.txt.pp                    |  2 +-
 compiler/simplCore/SimplUtils.hs                   | 33 +++++++----
 testsuite/tests/simplCore/should_run/T15436.hs     | 21 +++++++
 testsuite/tests/simplCore/should_run/T15436.stdout |  1 +
 testsuite/tests/simplCore/should_run/all.T         |  1 +
 6 files changed, 90 insertions(+), 32 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 851f3341953587d9fd2e471994b37ad81f132b1a


More information about the ghc-commits mailing list