Commit d46ae075 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-03-24 15:11:07 by simonmar]

mkStgAltType: try to find the non-abstract TyCon if the one in the
type of the case binder turns out to be an HiBootTyCon.  Fixes
possible code generation bugs when compiling programs with recursive
parent b6b182f3
......@@ -12,7 +12,7 @@ module CoreToStg ( coreToStg, coreExprToStg ) where
#include "HsVersions.h"
import CoreSyn
import CoreUtils ( rhsIsStatic, manifestArity, exprType )
import CoreUtils ( rhsIsStatic, manifestArity, exprType, findDefault )
import StgSyn
import Type
......@@ -371,7 +371,7 @@ coreToStgExpr (Case scrut bndr _ alts)
(getLiveVars alts_lv_info)
(mkSRT alts_lv_info)
(mkStgAltType (idType bndr))
(mkStgAltType (idType bndr) alts)
scrut_fvs `unionFVInfo` alts_fvs_wo_bndr,
alts_escs_wo_bndr `unionVarSet` getFVSet scrut_fvs
......@@ -411,15 +411,29 @@ coreToStgExpr (Let bind body)
mkStgAltType scrut_ty
mkStgAltType scrut_ty alts
= case splitTyConApp_maybe (repType scrut_ty) of
Just (tc,_) | isUnboxedTupleTyCon tc -> UbxTupAlt tc
| isPrimTyCon tc -> PrimAlt tc
| isHiBootTyCon tc -> PolyAlt -- Algebraic, but no constructors visible
| isHiBootTyCon tc -> look_for_better_tycon
| isAlgTyCon tc -> AlgAlt tc
| isFunTyCon tc -> PolyAlt
| otherwise -> pprPanic "mkStgAlts" (ppr tc)
Nothing -> PolyAlt
-- Sometimes, the TyCon in the type of the scrutinee is an HiBootTyCon,
-- which may not have any constructors inside it. If so, then we
-- can get a better TyCon by grabbing the one from a constructor alternative
-- if one exists.
| ((DataAlt con, _, _) : _) <- data_alts =
AlgAlt (dataConTyCon con)
| otherwise =
ASSERT(null data_alts)
(data_alts, deflt) = findDefault alts
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment