[commit: ghc] ghc-8.4: Fix PrelRules.caseRules to account for out-of-range tags (2ca7ced)
git at git.haskell.org
git at git.haskell.org
Sat Oct 13 19:11:15 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.4
Link : http://ghc.haskell.org/trac/ghc/changeset/2ca7ced93b41e98c2f0fbd8a4d958a1640432937/ghc
>---------------------------------------------------------------
commit 2ca7ced93b41e98c2f0fbd8a4d958a1640432937
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)
>---------------------------------------------------------------
2ca7ced93b41e98c2f0fbd8a4d958a1640432937
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 2ca7ced93b41e98c2f0fbd8a4d958a1640432937
More information about the ghc-commits
mailing list