summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-09-21 20:07:04 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2020-10-29 04:18:52 -0400
commit2ef2fac4c412a25fa64f79b759d69d22a4ebc784 (patch)
treeafe8262c627704f420916df1d010f53c1346081c /compiler/GHC/Hs
parent22f5d9a951dbc9cfdf55984c5e2a6fad28a6f650 (diff)
downloadhaskell-2ef2fac4c412a25fa64f79b759d69d22a4ebc784.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/Hs')
-rw-r--r--compiler/GHC/Hs/Type.hs13
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/GHC/Hs/Type.hs b/compiler/GHC/Hs/Type.hs
index a193eefa12..ed3b20a0ec 100644
--- a/compiler/GHC/Hs/Type.hs
+++ b/compiler/GHC/Hs/Type.hs
@@ -1060,20 +1060,19 @@ namely HsTupleTy, but keep track of the tuple kind (in the first argument to
HsTupleTy, a HsTupleSort). We can tell if a tuple is unboxed while parsing,
because of the #. However, with -XConstraintKinds we can only distinguish
between constraint and boxed tuples during type checking, in general. Hence the
-four constructors of HsTupleSort:
+two constructors of HsTupleSort:
HsUnboxedTuple -> Produced by the parser
- HsBoxedTuple -> Certainly a boxed tuple
- HsConstraintTuple -> Certainly a constraint tuple
HsBoxedOrConstraintTuple -> Could be a boxed or a constraint
tuple. Produced by the parser only,
disappears after type checking
+
+After typechecking, we use TupleSort (which clearly distinguishes between
+constraint tuples and boxed tuples) rather than HsTupleSort.
-}
-- | Haskell Tuple Sort
data HsTupleSort = HsUnboxedTuple
- | HsBoxedTuple
- | HsConstraintTuple
| HsBoxedOrConstraintTuple
deriving Data
@@ -1988,11 +1987,9 @@ hsTypeNeedsParens p = go_hs_ty
-- Special-case unary boxed tuple applications so that they are
-- parenthesized as `Identity (Solo x)`, not `Identity Solo x` (#18612)
-- See Note [One-tuples] in GHC.Builtin.Types
- go_hs_ty (HsTupleTy _ con [L _ ty])
+ go_hs_ty (HsTupleTy _ con [_])
= case con of
- HsBoxedTuple -> p >= appPrec
HsBoxedOrConstraintTuple -> p >= appPrec
- HsConstraintTuple -> go_hs_ty ty
HsUnboxedTuple -> False
go_hs_ty (HsTupleTy{}) = False
go_hs_ty (HsSumTy{}) = False