diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-01-15 13:51:55 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-01-15 14:26:25 -0500 |
commit | b92fb5150bdc6a0a090ecba2927c14e19005116e (patch) | |
tree | 3aaa985336c5dfa484fe02d85cf1f9ff78901e3b | |
parent | 20afdaa75e269697c2f9608e6d29f720a6387d01 (diff) | |
download | haskell-b92fb5150bdc6a0a090ecba2927c14e19005116e.tar.gz |
Parenthesize forall-type args in cvtTypeKind
Trac #14646 happened because we forgot to parenthesize `forall` types to
the left of an arrow. This simple patch fixes that.
Test Plan: make test TEST=T14646
Reviewers: alanz, goldfire, bgamari
Reviewed By: alanz
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #14646
Differential Revision: https://phabricator.haskell.org/D4298
(cherry picked from commit f380115cd834ffbe51aca60f5476a51b94cdd413)
-rw-r--r-- | compiler/hsSyn/Convert.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/th/T14646.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/th/T14646.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 |
4 files changed, 18 insertions, 4 deletions
diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs index b032538a66..aea37c9bc6 100644 --- a/compiler/hsSyn/Convert.hs +++ b/compiler/hsSyn/Convert.hs @@ -1221,10 +1221,11 @@ cvtTypeKind ty_str ty tys' ArrowT | [x',y'] <- tys' -> do - case x' of - (L _ HsFunTy{}) -> do { x'' <- returnL (HsParTy x') - ; returnL (HsFunTy x'' y') } - _ -> returnL (HsFunTy x' y') + x'' <- case x' of + L _ HsFunTy{} -> returnL (HsParTy x') + L _ HsForAllTy{} -> returnL (HsParTy x') -- #14646 + _ -> return x' + returnL (HsFunTy x'' y') | otherwise -> mk_apps (HsTyVar NotPromoted (noLoc (getRdrName funTyCon))) tys' diff --git a/testsuite/tests/th/T14646.hs b/testsuite/tests/th/T14646.hs new file mode 100644 index 0000000000..c85872365f --- /dev/null +++ b/testsuite/tests/th/T14646.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TemplateHaskell #-} +module T14646 where + +$([d| f :: (forall a. a) -> Int + f _ = undefined |]) diff --git a/testsuite/tests/th/T14646.stderr b/testsuite/tests/th/T14646.stderr new file mode 100644 index 0000000000..869cf6fd01 --- /dev/null +++ b/testsuite/tests/th/T14646.stderr @@ -0,0 +1,6 @@ +T14646.hs:(5,3)-(6,24): Splicing declarations + [d| f :: (forall a. a) -> Int + f _ = undefined |] + ======> + f :: (forall a. a) -> Int + f _ = undefined diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 0ad178e691..1fae4c6af8 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -397,3 +397,4 @@ test('T13887', normal, compile_and_run, ['-v0']) test('T13968', normal, compile_fail, ['-v0']) test('T14204', normal, compile_fail, ['-v0']) test('T14060', normal, compile_and_run, ['-v0']) +test('T14646', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) |