diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-09-21 20:07:04 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-10-29 04:18:52 -0400 |
commit | 2ef2fac4c412a25fa64f79b759d69d22a4ebc784 (patch) | |
tree | afe8262c627704f420916df1d010f53c1346081c /compiler/GHC/Tc/Gen/Expr.hs | |
parent | 22f5d9a951dbc9cfdf55984c5e2a6fad28a6f650 (diff) | |
download | haskell-wip/T18723.tar.gz |
Check for large tuples more thoroughlywip/T18723
This fixes #18723 by:
* Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity
check to `GHC.Rename.Utils.checkCTupSize` for consistency with
`GHC.Rename.Utils.checkTupSize`, and
* Using `check(C)TupSize` when checking tuple _types_, in addition
to checking names, expressions, and patterns.
Note that I put as many of these checks as possible in the typechecker so
that GHC can properly distinguish between boxed and constraint tuples. The
exception to this rule is checking names, which I perform in the renamer
(in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and
`''(,, ... ,,)` alike in one fell swoop.
While I was in town, I also removed the `HsConstraintTuple` and
`HsBoxedTuple` constructors of `HsTupleSort`, which are functionally
unused. This requires a `haddock` submodule bump.
Diffstat (limited to 'compiler/GHC/Tc/Gen/Expr.hs')
-rw-r--r-- | compiler/GHC/Tc/Gen/Expr.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs index 564ad46660..5d919280f0 100644 --- a/compiler/GHC/Tc/Gen/Expr.hs +++ b/compiler/GHC/Tc/Gen/Expr.hs @@ -32,6 +32,7 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Tc.Gen.Splice( tcSpliceExpr, tcTypedBracket, tcUntypedBracket ) import GHC.Hs +import GHC.Rename.Utils import GHC.Tc.Utils.Zonk import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Unify @@ -1036,7 +1037,9 @@ arithSeqEltType (Just fl) res_ty ---------------- tcTupArgs :: [LHsTupArg GhcRn] -> [TcSigmaType] -> TcM [LHsTupArg GhcTc] tcTupArgs args tys - = ASSERT( equalLength args tys ) mapM go (args `zip` tys) + = do MASSERT( equalLength args tys ) + checkTupSize (length args) + mapM go (args `zip` tys) where go (L l (Missing {}), arg_ty) = do { mult <- newFlexiTyVarTy multiplicityTy ; return (L l (Missing (Scaled mult arg_ty))) } |