summaryrefslogtreecommitdiff
path: root/testsuite/tests/printer
diff options
context:
space:
mode:
authorAndreas Herrmann <andreash87@gmx.ch>2018-06-07 13:24:52 -0400
committerBen Gamari <ben@smart-cactus.org>2018-06-07 18:06:29 -0400
commit767536ccf95d8352d146b6544857b28d9c42937e (patch)
treec0d3f6d4d6b6977ed9835c9e5617aba746765d57 /testsuite/tests/printer
parente7678d6a0607013749e9ba4d88df949ad1192765 (diff)
downloadhaskell-767536ccf95d8352d146b6544857b28d9c42937e.tar.gz
Fix unparseable pretty-printing of promoted data cons
Previously we would print code which would not round-trip: ``` > :set -XDataKinds > :set -XPolyKinds > data Proxy k = Proxy > _ :: Proxy '[ 'True ] error: Found hole: _ :: Proxy '['True] > _ :: Proxy '['True] error: Invalid type signature: _ :: ... Should be of form <variable> :: <type> ``` Test Plan: Validate with T14343 Reviewers: RyanGlScott, goldfire, bgamari, tdammers Reviewed By: RyanGlScott, bgamari Subscribers: tdammers, rwbarton, thomie, carter GHC Trac Issues: #14343 Differential Revision: https://phabricator.haskell.org/D4746
Diffstat (limited to 'testsuite/tests/printer')
-rw-r--r--testsuite/tests/printer/Makefile8
-rw-r--r--testsuite/tests/printer/T14343.hs12
-rw-r--r--testsuite/tests/printer/T14343.stderr36
-rw-r--r--testsuite/tests/printer/T14343b.hs12
-rw-r--r--testsuite/tests/printer/T14343b.stderr39
-rw-r--r--testsuite/tests/printer/all.T2
6 files changed, 109 insertions, 0 deletions
diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile
index 17fc65215f..044e44332e 100644
--- a/testsuite/tests/printer/Makefile
+++ b/testsuite/tests/printer/Makefile
@@ -229,3 +229,11 @@ T14289c:
.PHONY: T14306
T14306:
$(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T14306.hs
+
+.PHONY: T14343
+T14343:
+ $(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T14343.hs
+
+.PHONY: T14343b
+T14343b:
+ $(CHECK_PPR) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" T14343b.hs
diff --git a/testsuite/tests/printer/T14343.hs b/testsuite/tests/printer/T14343.hs
new file mode 100644
index 0000000000..1fe6a9660b
--- /dev/null
+++ b/testsuite/tests/printer/T14343.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE PolyKinds #-}
+{-# OPTIONS_GHC -Werror=typed-holes #-}
+
+main :: IO ()
+main = undefined
+
+data Proxy k = Proxy
+
+test1 = _ :: Proxy '[ 'True ]
+test2 = _ :: Proxy '[ '[ 1 ] ]
+test3 = _ :: Proxy '[ '( "Symbol", 1 ) ]
diff --git a/testsuite/tests/printer/T14343.stderr b/testsuite/tests/printer/T14343.stderr
new file mode 100644
index 0000000000..1bceb67403
--- /dev/null
+++ b/testsuite/tests/printer/T14343.stderr
@@ -0,0 +1,36 @@
+
+T14343.hs:10:9: error:
+ • Found hole: _ :: Proxy '[ 'True]
+ • In the expression: _ :: Proxy '[ 'True]
+ In an equation for ‘test1’: test1 = _ :: Proxy '[ 'True]
+ • Relevant bindings include
+ test1 :: Proxy '[ 'True] (bound at T14343.hs:10:1)
+ Valid hole fits include
+ test1 :: Proxy '[ 'True] (defined at T14343.hs:10:1)
+ Proxy :: forall k1 (k2 :: k1). Proxy k2
+ with Proxy @[Bool] @'[ 'True]
+ (defined at T14343.hs:8:16)
+
+T14343.hs:11:9: error:
+ • Found hole: _ :: Proxy '[ '[1]]
+ • In the expression: _ :: Proxy '['[1]]
+ In an equation for ‘test2’: test2 = _ :: Proxy '['[1]]
+ • Relevant bindings include
+ test2 :: Proxy '[ '[1]] (bound at T14343.hs:11:1)
+ Valid hole fits include
+ test2 :: Proxy '[ '[1]] (defined at T14343.hs:11:1)
+ Proxy :: forall k1 (k2 :: k1). Proxy k2
+ with Proxy @[[GHC.Types.Nat]] @'[ '[1]]
+ (defined at T14343.hs:8:16)
+
+T14343.hs:12:9: error:
+ • Found hole: _ :: Proxy '[ '("Symbol", 1)]
+ • In the expression: _ :: Proxy '['("Symbol", 1)]
+ In an equation for ‘test3’: test3 = _ :: Proxy '['("Symbol", 1)]
+ • Relevant bindings include
+ test3 :: Proxy '[ '("Symbol", 1)] (bound at T14343.hs:12:1)
+ Valid hole fits include
+ test3 :: Proxy '[ '("Symbol", 1)] (defined at T14343.hs:12:1)
+ Proxy :: forall k1 (k2 :: k1). Proxy k2
+ with Proxy @[(GHC.Types.Symbol, GHC.Types.Nat)] @'[ '("Symbol", 1)]
+ (defined at T14343.hs:8:16)
diff --git a/testsuite/tests/printer/T14343b.hs b/testsuite/tests/printer/T14343b.hs
new file mode 100644
index 0000000000..6596a7a486
--- /dev/null
+++ b/testsuite/tests/printer/T14343b.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE PolyKinds #-}
+{-# OPTIONS_GHC -Werror=typed-holes #-}
+
+main :: IO ()
+main = undefined
+
+data Proxy k = Proxy
+
+test1 = _ :: Proxy '( 'True, 'False )
+test2 = _ :: Proxy '( '( 'True, 'False ), 'False )
+test3 = _ :: Proxy '( '[ 1 ], 'False )
diff --git a/testsuite/tests/printer/T14343b.stderr b/testsuite/tests/printer/T14343b.stderr
new file mode 100644
index 0000000000..1954f9465a
--- /dev/null
+++ b/testsuite/tests/printer/T14343b.stderr
@@ -0,0 +1,39 @@
+
+T14343b.hs:10:9: error:
+ • Found hole: _ :: Proxy '( 'True, 'False)
+ • In the expression: _ :: Proxy '( 'True, 'False)
+ In an equation for ‘test1’: test1 = _ :: Proxy '( 'True, 'False)
+ • Relevant bindings include
+ test1 :: Proxy '( 'True, 'False) (bound at T14343b.hs:10:1)
+ Valid hole fits include
+ test1 :: Proxy '( 'True, 'False) (defined at T14343b.hs:10:1)
+ Proxy :: forall k1 (k2 :: k1). Proxy k2
+ with Proxy @(Bool, Bool) @'( 'True, 'False)
+ (defined at T14343b.hs:8:16)
+
+T14343b.hs:11:9: error:
+ • Found hole: _ :: Proxy '( '( 'True, 'False), 'False)
+ • In the expression: _ :: Proxy '('( 'True, 'False), 'False)
+ In an equation for ‘test2’:
+ test2 = _ :: Proxy '('( 'True, 'False), 'False)
+ • Relevant bindings include
+ test2 :: Proxy '( '( 'True, 'False), 'False)
+ (bound at T14343b.hs:11:1)
+ Valid hole fits include
+ test2 :: Proxy '( '( 'True, 'False), 'False)
+ (defined at T14343b.hs:11:1)
+ Proxy :: forall k1 (k2 :: k1). Proxy k2
+ with Proxy @((Bool, Bool), Bool) @'( '( 'True, 'False), 'False)
+ (defined at T14343b.hs:8:16)
+
+T14343b.hs:12:9: error:
+ • Found hole: _ :: Proxy '( '[1], 'False)
+ • In the expression: _ :: Proxy '('[1], 'False)
+ In an equation for ‘test3’: test3 = _ :: Proxy '('[1], 'False)
+ • Relevant bindings include
+ test3 :: Proxy '( '[1], 'False) (bound at T14343b.hs:12:1)
+ Valid hole fits include
+ test3 :: Proxy '( '[1], 'False) (defined at T14343b.hs:12:1)
+ Proxy :: forall k1 (k2 :: k1). Proxy k2
+ with Proxy @([GHC.Types.Nat], Bool) @'( '[1], 'False)
+ (defined at T14343b.hs:8:16)
diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T
index 7dda6b36fa..203efa4be4 100644
--- a/testsuite/tests/printer/all.T
+++ b/testsuite/tests/printer/all.T
@@ -54,3 +54,5 @@ test('T14289', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T1428
test('T14289b', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T14289b'])
test('T14289c', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T14289c'])
test('T14306', ignore_stderr, run_command, ['$MAKE -s --no-print-directory T14306'])
+test('T14343', normal, compile_fail, [''])
+test('T14343b', normal, compile_fail, [''])