[Git][ghc/ghc][wip/T21623] Wibbles

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Wed Sep 28 14:27:21 UTC 2022



Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC


Commits:
83c2c74a by Simon Peyton Jones at 2022-09-28T15:29:19+01:00
Wibbles

- - - - -


2 changed files:

- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Core/Make.hs


Changes:

=====================================
compiler/GHC/Builtin/Types.hs
=====================================
@@ -1934,9 +1934,8 @@ boxingDataCon_maybe :: HasDebugCallStack => Type -> Maybe (DataCon, Type)
 --   will box it, and the type of the boxed thing, which /does/ now have kind Type.
 --
 --   Nothing => no boxing necessary (already of kind Type)
---              or no suitable boxing data constructor is available.
 --
--- This variant panics if it is given an unlifted type
+-- This variant panics if it is given a non-TYPE type
 -- that it does not know how to box.
 boxingDataCon_maybe ty
   | tcIsLiftedTypeKind kind
@@ -1956,7 +1955,8 @@ boxingDataConUnlifted_maybe :: HasDebugCallStack => Type -> Maybe (DataCon, Type
 --              or no suitable boxing data constructor is available.
 --
 -- This variant expects the type to be unlifted, and does not
--- fail if there is no suitable DataCon; used in SetLevels
+-- fail if there is no suitable DataCon (it returns Nothing instead);
+-- used in SetLevels
 boxingDataConUnlifted_maybe ty
   | Just box_con <- lookupTypeMap boxingDataConMap kind
   = Just (box_con, mkTyConApp (dataConTyCon box_con) [ty])


=====================================
compiler/GHC/Core/Make.hs
=====================================
@@ -375,8 +375,7 @@ mkCoreBoxedTuple cs
                   (map (Type . exprType) cs ++ cs)
 
 
--- | Build a small unboxed tuple holding the specified expressions,
--- with the given types. The types must be the types of the expressions.
+-- | Build a small unboxed tuple holding the specified expressions.
 -- Do not include the RuntimeRep specifiers; this function calculates them
 -- for you.
 -- Does /not/ flatten one-tuples; see Note [Flattening one-tuples]
@@ -449,10 +448,10 @@ But see Note [Don't flatten tuples from HsSyn]
 -}
 
 mkBigCoreVarTupSolo :: [Id] -> CoreExpr
--- Same as mkBigCoreVarTup, but
+-- Same as mkBigCoreVarTup, but:
 --   - one-tuples are not flattened
 --     see Note [Flattening one-tuples]
---   - arguements should have kind Type
+--   - arguments should have kind Type
 mkBigCoreVarTupSolo [id] = mkCoreBoxedTuple [Var id]
 mkBigCoreVarTupSolo ids  = mkChunkified mkCoreTup (map Var ids)
 
@@ -464,7 +463,9 @@ mkBigCoreVarTup ids = mkBigCoreTup (map Var ids)
 
 -- | Build a "big" tuple holding the specified expressions
 -- One-tuples are flattened; see Note [Flattening one-tuples]
--- Arguments don't have to have kind Type
+-- Arguments don't have to have kind Type; ones that do not are boxed
+-- This function crashes (in boxingDataCon_maybe) if given a non-Type
+-- argument that it doesn't know how to box.
 mkBigCoreTup :: [CoreExpr] -> CoreExpr
 mkBigCoreTup exprs = mkChunkified mkCoreTup (map wrapBox exprs)
 
@@ -490,6 +491,7 @@ wrapBox :: CoreExpr -> CoreExpr
 --     which has kind Type
 -- where K is the boxing data constructor for ki
 -- See Note [Boxing constructors] in GHC.Builtin.Types
+-- Crashes in boxingDataCon_maybe if there /is/ no boxing data con
 wrapBox e
   | Just (boxing_con, _) <- boxingDataCon_maybe e_ty
   = mkCoreConApps boxing_con [Type e_ty, e]



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83c2c74a1800e1fb9535413fa18976b84ad6295e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83c2c74a1800e1fb9535413fa18976b84ad6295e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220928/e3cbf7cd/attachment-0001.html>


More information about the ghc-commits mailing list