summaryrefslogtreecommitdiff
path: root/compiler/ghci/ByteCodeGen.hs
diff options
context:
space:
mode:
authorSeraphime Kirkovski <kirkseraph@gmail.com>2016-07-20 09:47:23 +0200
committerBen Gamari <ben@smart-cactus.org>2016-07-20 15:17:50 +0200
commit8de6e13f9ef784750e502955fcb38d4a7e179727 (patch)
tree5c4755be247b3d6ec2f5b83374b7993628851a67 /compiler/ghci/ByteCodeGen.hs
parent908f8e234fdbf951e763e0c47b018c6f74ae952c (diff)
downloadhaskell-8de6e13f9ef784750e502955fcb38d4a7e179727.tar.gz
Fix bytecode generator panic
This fixes #12128. The bug was introduced in 1c9fd3f1c5522372fcaf250c805b959e8090a62c. Test Plan: ./validate Reviewers: simonmar, austin, hvr, simonpj, bgamari Reviewed By: bgamari Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D2374 GHC Trac Issues: #12128
Diffstat (limited to 'compiler/ghci/ByteCodeGen.hs')
-rw-r--r--compiler/ghci/ByteCodeGen.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs
index 0d4c64b4d1..8839ffa544 100644
--- a/compiler/ghci/ByteCodeGen.hs
+++ b/compiler/ghci/ByteCodeGen.hs
@@ -1327,6 +1327,12 @@ pushAtom d p e
pushAtom _ _ (AnnCoercion {}) -- Coercions are zero-width things,
= return (nilOL, 0) -- treated just like a variable V
+-- See Note [Empty case alternatives] in coreSyn/CoreSyn.hs
+-- and Note [Bottoming expressions] in coreSyn/CoreUtils.hs:
+-- The scrutinee of an empty case evaluates to bottom
+pushAtom d p (AnnCase (_, a) _ _ []) -- trac #12128
+ = pushAtom d p a
+
pushAtom d p (AnnVar v)
| UnaryRep rep_ty <- repType (idType v)
, V <- typeArgRep rep_ty
@@ -1627,6 +1633,11 @@ atomPrimRep :: AnnExpr' Id ann -> PrimRep
atomPrimRep e | Just e' <- bcView e = atomPrimRep e'
atomPrimRep (AnnVar v) = bcIdPrimRep v
atomPrimRep (AnnLit l) = typePrimRep (literalType l)
+
+-- Trac #12128:
+-- A case expresssion can be an atom because empty cases evaluate to bottom.
+-- See Note [Empty case alternatives] in coreSyn/CoreSyn.hs
+atomPrimRep (AnnCase _ _ ty _) = ASSERT(typePrimRep ty == PtrRep) PtrRep
atomPrimRep (AnnCoercion {}) = VoidRep
atomPrimRep other = pprPanic "atomPrimRep" (ppr (deAnnotate' other))