diff options
| author | Max Bolingbroke <batterseapower@hotmail.com> | 2012-03-07 16:30:05 +0000 |
|---|---|---|
| committer | Max Bolingbroke <batterseapower@hotmail.com> | 2012-03-07 16:30:05 +0000 |
| commit | 5474db75dbe4071cb809c548ac0b4e009e210f51 (patch) | |
| tree | 7cd7f97fca8b7b9122052cd7b054be76076331af /compiler/ghci | |
| parent | eb736fc1d1482601c942cabbd19b94e3a7cf3df7 (diff) | |
| download | haskell-5474db75dbe4071cb809c548ac0b4e009e210f51.tar.gz | |
Fix bugs exposed by testsuite run
Diffstat (limited to 'compiler/ghci')
| -rw-r--r-- | compiler/ghci/RtClosureInspect.hs | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs index 3a8c9ff6f0..3c2507b391 100644 --- a/compiler/ghci/RtClosureInspect.hs +++ b/compiler/ghci/RtClosureInspect.hs @@ -795,7 +795,20 @@ extractSubTerms recurse clos = liftM thirdOf3 . go 0 (nonPtrs clos) return (ptr_i, ws, terms0 ++ terms1) | otherwise = case typePrimRep ty of - [] -> go ptr_i ws tys + [] -> do + -- If we confirm that this is a type represented by void then + -- we can represent it as a nullary Prim in the output term. + -- This is necessary so that for a GADT like this: + -- data Foo a where FooCon :: Int -> Foo Int + -- + -- The output Term looks like: + -- Term (Left Foo) [Prim [], Term (Left I#) [..]] + -- + -- This is that when we drop the "theta" from the list of + -- terms when displaying the Foo, we drop the (Prim []) and NOT + -- the Term (Left I#). If you don't do this then print012 will fail. + (ptr_i, ws, terms) <- go ptr_i ws tys + return (ptr_i, ws, Prim ty [] : terms) [rep] -> do (ptr_i, ws, term0) <- go_rep ptr_i ws ty rep (ptr_i, ws, terms1) <- go ptr_i ws tys @@ -821,44 +834,6 @@ extractSubTerms recurse clos = liftM thirdOf3 . go 0 (nonPtrs clos) return (ptr_i, ws1, Prim ty ws0) - - {- - let (subTtypesP, subTtypesNP) = partition isPtrType subTtypes - subTermsP <- sequence - [ appArr (go (pred max_depth) ty ty) (ptrs clos) i - | (i,ty) <- zip [0..] subTtypesP] - let unboxeds = extractUnboxed subTtypesNP clos - subTermsNP = zipWith Prim subTtypesNP unboxeds - subTerms = reOrderTerms subTermsP subTermsNP subTtypes - - - -extractUnboxed :: [Type] -> Closure -> [[Word]] -extractUnboxed tt clos = go tt (nonPtrs clos) - where sizeofType t = primRepSizeW (typePrimRep t) - go [] _ = [] - go (t:tt) xx - | (x, rest) <- splitAt (sizeofType t) xx - = x : go tt rest - - - - - -- put together pointed and nonpointed subterms in the - -- correct order. - reOrderTerms _ _ [] = [] - reOrderTerms pointed unpointed (ty:tys) - | isPtrType ty = ASSERT2(not(null pointed) - , ptext (sLit "reOrderTerms") $$ - (ppr pointed $$ ppr unpointed)) - let (t:tt) = pointed in t : reOrderTerms tt unpointed tys - | otherwise = ASSERT2(not(null unpointed) - , ptext (sLit "reOrderTerms") $$ - (ppr pointed $$ ppr unpointed)) - let (t:tt) = unpointed in t : reOrderTerms pointed tt tys - -} - - -- Fast, breadth-first Type reconstruction ------------------------------------------ cvReconstructType :: HscEnv -> Int -> GhciType -> HValue -> IO (Maybe Type) |
