diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2021-05-03 20:29:56 +0200 |
---|---|---|
committer | Andreas Klebinger <klebinger.andreas@gmx.at> | 2021-05-04 16:07:11 +0200 |
commit | e5121b709d613dd5eee34bf97d397f8ec947c763 (patch) | |
tree | 97a907f2061115b3d847243d1932878ee88a7fa6 | |
parent | 24a9b1708cee95670e7ec2a6ceb68e29fc376cf7 (diff) | |
download | haskell-wip/andreask/stgLint.tar.gz |
StgLint: Compare constructor arity to alternative binder count.wip/andreask/stgLint
-rw-r--r-- | compiler/GHC/Stg/Lint.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/GHC/Stg/Lint.hs b/compiler/GHC/Stg/Lint.hs index abdc5e8328..d22e355b2b 100644 --- a/compiler/GHC/Stg/Lint.hs +++ b/compiler/GHC/Stg/Lint.hs @@ -232,7 +232,14 @@ lintAlt (DEFAULT, _, rhs) = lintAlt (LitAlt _, _, rhs) = lintStgExpr rhs -lintAlt (DataAlt _, bndrs, rhs) = do +lintAlt (DataAlt con, bndrs, rhs) = do + when (dataConRepArity con /= length bndrs) $ do + opts <- getStgPprOpts + addErrL (text "DataConRep arity doesn't match binder count!" $$ + text "DataCon:" <> ppr con $$ + text "Arity:" <> ppr (dataConRepArity con) $$ + text "Binders:" <> ppr bndrs $$ + text "RHS:" <> pprStgExpr opts rhs) mapM_ checkPostUnariseBndr bndrs addInScopeVars bndrs (lintStgExpr rhs) |