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 /testsuite | |
parent | 22f5d9a951dbc9cfdf55984c5e2a6fad28a6f650 (diff) | |
download | haskell-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 'testsuite')
18 files changed, 283 insertions, 31 deletions
diff --git a/testsuite/tests/rename/should_fail/T6148.hs b/testsuite/tests/rename/should_fail/T6148.hs deleted file mode 100644 index 6b0b05bb36..0000000000 --- a/testsuite/tests/rename/should_fail/T6148.hs +++ /dev/null @@ -1,15 +0,0 @@ -module T6148 where - -a = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) - - -b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) - -data T = T - -c :: (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) - T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T - T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T - T T T T T -c = c diff --git a/testsuite/tests/rename/should_fail/T6148.stderr b/testsuite/tests/rename/should_fail/T6148.stderr deleted file mode 100644 index 0e0df64113..0000000000 --- a/testsuite/tests/rename/should_fail/T6148.stderr +++ /dev/null @@ -1,15 +0,0 @@ - -T6148.hs:3:5: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type - -T6148.hs:7:5: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type - -T6148.hs:11:6: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type diff --git a/testsuite/tests/rename/should_fail/T6148a.hs b/testsuite/tests/rename/should_fail/T6148a.hs new file mode 100644 index 0000000000..691899ce47 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148a.hs @@ -0,0 +1,4 @@ +module T6148a where + +a = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) diff --git a/testsuite/tests/rename/should_fail/T6148a.stderr b/testsuite/tests/rename/should_fail/T6148a.stderr new file mode 100644 index 0000000000..e287636d4d --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148a.stderr @@ -0,0 +1,14 @@ + +T6148a.hs:3:5: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the expression: + (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + In an equation for ‘a’: + a = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0) diff --git a/testsuite/tests/rename/should_fail/T6148b.hs b/testsuite/tests/rename/should_fail/T6148b.hs new file mode 100644 index 0000000000..41f11158f7 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148b.hs @@ -0,0 +1,3 @@ +module T6148b where + +b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) diff --git a/testsuite/tests/rename/should_fail/T6148b.stderr b/testsuite/tests/rename/should_fail/T6148b.stderr new file mode 100644 index 0000000000..3c5afcd085 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148b.stderr @@ -0,0 +1,5 @@ + +T6148b.hs:3:5: error: + A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type diff --git a/testsuite/tests/rename/should_fail/T6148c.hs b/testsuite/tests/rename/should_fail/T6148c.hs new file mode 100644 index 0000000000..46454ee022 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148c.hs @@ -0,0 +1,9 @@ +module T6148c where + +data T = T + +c :: (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) + T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T + T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T + T T T T T +c = c diff --git a/testsuite/tests/rename/should_fail/T6148c.stderr b/testsuite/tests/rename/should_fail/T6148c.stderr new file mode 100644 index 0000000000..a11d23ccac --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148c.stderr @@ -0,0 +1,5 @@ + +T6148c.hs:5:6: error: + A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type diff --git a/testsuite/tests/rename/should_fail/T6148d.hs b/testsuite/tests/rename/should_fail/T6148d.hs new file mode 100644 index 0000000000..4828d44908 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148d.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE UnboxedTuples #-} +module T6148d where + +d1 = ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) +d2 = '(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) +d3 = ''(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) +d4 = '(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) diff --git a/testsuite/tests/rename/should_fail/T6148d.stderr b/testsuite/tests/rename/should_fail/T6148d.stderr new file mode 100644 index 0000000000..774c96e540 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T6148d.stderr @@ -0,0 +1,28 @@ + +T6148d.hs:5:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) + +T6148d.hs:6:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + '(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) + +T6148d.hs:7:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + ''(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) + +T6148d.hs:8:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + '(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index e380a913ad..81285649ce 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -87,7 +87,10 @@ test('T5892b', normal, compile_fail, ['-package containers']) test('T5951', normal, compile_fail, ['']) test('T6018rnfail', normal, compile_fail, ['']) test('T6060', normal, compile_fail, ['']) -test('T6148', normal, compile_fail, ['']) +test('T6148a', normal, compile_fail, ['']) +test('T6148b', normal, compile_fail, ['']) +test('T6148c', normal, compile_fail, ['']) +test('T6148d', normal, compile_fail, ['']) test('T7164', normal, compile_fail, ['']) test('T7338', normal, compile_fail, ['']) test('T7338a', normal, compile_fail, ['']) diff --git a/testsuite/tests/typecheck/should_fail/T18723a.hs b/testsuite/tests/typecheck/should_fail/T18723a.hs new file mode 100644 index 0000000000..0bb9e73fdf --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T18723a.hs @@ -0,0 +1,11 @@ +module T18723a where + +data T1 = MkT1 + ( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + ) diff --git a/testsuite/tests/typecheck/should_fail/T18723a.stderr b/testsuite/tests/typecheck/should_fail/T18723a.stderr new file mode 100644 index 0000000000..cb599b3737 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T18723a.stderr @@ -0,0 +1,13 @@ + +T18723a.hs:4:3: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int)’ + In the definition of data constructor ‘MkT1’ + In the data declaration for ‘T1’ diff --git a/testsuite/tests/typecheck/should_fail/T18723b.hs b/testsuite/tests/typecheck/should_fail/T18723b.hs new file mode 100644 index 0000000000..3905a3eeee --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T18723b.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE DataKinds #-} +module T18723b where + +import Data.Proxy + +data T2 = MkT2 (Proxy + '( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + )) diff --git a/testsuite/tests/typecheck/should_fail/T18723b.stderr b/testsuite/tests/typecheck/should_fail/T18723b.stderr new file mode 100644 index 0000000000..f0f8936b5d --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T18723b.stderr @@ -0,0 +1,137 @@ + +T18723b.hs:7:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the first argument of ‘Proxy’, namely + ‘'(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int)’ + In the type ‘(Proxy '(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int))’ + In the definition of data constructor ‘MkT2’ diff --git a/testsuite/tests/typecheck/should_fail/T18723c.hs b/testsuite/tests/typecheck/should_fail/T18723c.hs new file mode 100644 index 0000000000..8bfe96cb97 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T18723c.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE UnboxedTuples #-} +module T18723c where + +data T3 = MkT3 + (# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + #) diff --git a/testsuite/tests/typecheck/should_fail/T18723c.stderr b/testsuite/tests/typecheck/should_fail/T18723c.stderr new file mode 100644 index 0000000000..d1245b7758 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T18723c.stderr @@ -0,0 +1,13 @@ + +T18723c.hs:5:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int #)’ + In the definition of data constructor ‘MkT3’ + In the data declaration for ‘T3’ diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 54814bdc6a..1a260c5dc4 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -580,6 +580,9 @@ test('T18357b', normal, compile_fail, ['']) test('T18455', normal, compile_fail, ['']) test('T18534', normal, compile_fail, ['']) test('T18714', normal, compile_fail, ['']) +test('T18723a', normal, compile_fail, ['']) +test('T18723b', normal, compile_fail, ['']) +test('T18723c', normal, compile_fail, ['']) test('too-many', normal, compile_fail, ['']) test('T18640a', normal, compile_fail, ['']) test('T18640b', normal, compile_fail, ['']) |