[commit: ghc] master: Fix PrelRules.caseRules to account for out-of-range tags (9897f67)
git at git.haskell.org
git at git.haskell.org
Wed Jul 25 16:21:31 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/9897f6783a58265d5eaef5fb06f04320c7737e87/ghc
>---------------------------------------------------------------
commit 9897f6783a58265d5eaef5fb06f04320c7737e87
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
>---------------------------------------------------------------
9897f6783a58265d5eaef5fb06f04320c7737e87
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 9897f6783a58265d5eaef5fb06f04320c7737e87
More information about the ghc-commits
mailing list