[commit: ghc] wip/T12618: New Lint Check: No data con workers any more, please (70e58e8)

git at git.haskell.org git at git.haskell.org
Thu Oct 6 23:20:58 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T12618
Link       : http://ghc.haskell.org/trac/ghc/changeset/70e58e8316a138627274160e2fe6972802084fea/ghc

>---------------------------------------------------------------

commit 70e58e8316a138627274160e2fe6972802084fea
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Wed Oct 5 23:22:48 2016 -0400

    New Lint Check: No data con workers any more, please


>---------------------------------------------------------------

70e58e8316a138627274160e2fe6972802084fea
 compiler/coreSyn/CoreLint.hs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs
index 02b2a36..127ae0f 100644
--- a/compiler/coreSyn/CoreLint.hs
+++ b/compiler/coreSyn/CoreLint.hs
@@ -624,6 +624,7 @@ lintCoreExpr (Var var)
   = do  { checkL (isNonCoVarId var)
                  (text "Non term variable" <+> ppr var)
 
+        ; checkBadDataConWorker var
         ; checkDeadIdOcc var
         ; var' <- lookupIdInScope var
         ; return (idType var') }
@@ -898,6 +899,16 @@ checkDeadIdOcc id
   | otherwise
   = return ()
 
+checkBadDataConWorker :: Id -> LintM ()
+-- We do not want to see data con workers here, but for newtypes
+-- (It should either be a ConApp or a reference to the wrapper)
+checkBadDataConWorker id
+  | Just dc <- isDataConWorkId_maybe id
+  = checkL (isNewTyCon (dataConTyCon dc))
+           (text "data constructor worker found" <+> ppr id) 
+  | otherwise
+  = return ()
+
 {-
 ************************************************************************
 *                                                                      *



More information about the ghc-commits mailing list