[commit: ghc] ghc-8.6: Fix mkGadtDecl does not set con_forall correctly (a39b58d)

git at git.haskell.org git at git.haskell.org
Thu Jul 12 21:06:57 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/a39b58d511f177c9c476cc104999caa67a55de2a/ghc

>---------------------------------------------------------------

commit a39b58d511f177c9c476cc104999caa67a55de2a
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date:   Fri Jun 29 20:58:21 2018 +0200

    Fix mkGadtDecl does not set con_forall correctly
    
    A GADT declaration surrounded in parens does not det the con_forall
    field correctly.
    
    e.g.
    
    data MaybeDefault v where
        TestParens  :: (forall v . (Eq v) => MaybeDefault v)
    
    Closes #15323
    
    (cherry picked from commit 6e4e6d1c674a9d0257ca5c6caa26da18edf8ad8c)


>---------------------------------------------------------------

a39b58d511f177c9c476cc104999caa67a55de2a
 compiler/parser/RdrHsSyn.hs                        |  2 +-
 testsuite/tests/parser/should_compile/T15323.hs    |  6 ++
 .../tests/parser/should_compile/T15323.stderr      | 96 ++++++++++++++++++++++
 testsuite/tests/parser/should_compile/all.T        |  1 +
 4 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs
index a74d98a..ed5c592 100644
--- a/compiler/parser/RdrHsSyn.hs
+++ b/compiler/parser/RdrHsSyn.hs
@@ -643,7 +643,7 @@ mkGadtDecl :: [Located RdrName]
 mkGadtDecl names ty
   = (ConDeclGADT { con_g_ext  = noExt
                  , con_names  = names
-                 , con_forall = L l $ isLHsForAllTy ty
+                 , con_forall = L l $ isLHsForAllTy ty'
                  , con_qvars  = mkHsQTvs tvs
                  , con_mb_cxt = mcxt
                  , con_args   = args'
diff --git a/testsuite/tests/parser/should_compile/T15323.hs b/testsuite/tests/parser/should_compile/T15323.hs
new file mode 100644
index 0000000..ffc8ad8
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T15323.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE GADTs      #-}
+{-# LANGUAGE RankNTypes #-}
+module T15323 where
+
+data MaybeDefault v where
+    TestParens  :: (forall v . (Eq v) => MaybeDefault v)
diff --git a/testsuite/tests/parser/should_compile/T15323.stderr b/testsuite/tests/parser/should_compile/T15323.stderr
new file mode 100644
index 0000000..93b254b
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T15323.stderr
@@ -0,0 +1,96 @@
+
+==================== Parser AST ====================
+
+({ T15323.hs:1:1 }
+ (HsModule
+  (Just
+   ({ T15323.hs:3:8-13 }
+    {ModuleName: T15323}))
+  (Nothing)
+  []
+  [({ T15323.hs:(5,1)-(6,56) }
+    (TyClD
+     (NoExt)
+     (DataDecl
+      (NoExt)
+      ({ T15323.hs:5:6-17 }
+       (Unqual
+        {OccName: MaybeDefault}))
+      (HsQTvs
+       (NoExt)
+       [({ T15323.hs:5:19 }
+         (UserTyVar
+          (NoExt)
+          ({ T15323.hs:5:19 }
+           (Unqual
+            {OccName: v}))))])
+      (Prefix)
+      (HsDataDefn
+       (NoExt)
+       (DataType)
+       ({ <no location info> }
+        [])
+       (Nothing)
+       (Nothing)
+       [({ T15323.hs:6:5-56 }
+         (ConDeclGADT
+          (NoExt)
+          [({ T15323.hs:6:5-14 }
+            (Unqual
+             {OccName: TestParens}))]
+          ({ T15323.hs:6:21-55 }
+           (True))
+          (HsQTvs
+           (NoExt)
+           [({ T15323.hs:6:28 }
+             (UserTyVar
+              (NoExt)
+              ({ T15323.hs:6:28 }
+               (Unqual
+                {OccName: v}))))])
+          (Just
+           ({ T15323.hs:6:32-37 }
+            [({ T15323.hs:6:32-37 }
+              (HsParTy
+               (NoExt)
+               ({ T15323.hs:6:33-36 }
+                (HsAppTy
+                 (NoExt)
+                 ({ T15323.hs:6:33-34 }
+                  (HsTyVar
+                   (NoExt)
+                   (NotPromoted)
+                   ({ T15323.hs:6:33-34 }
+                    (Unqual
+                     {OccName: Eq}))))
+                 ({ T15323.hs:6:36 }
+                  (HsTyVar
+                   (NoExt)
+                   (NotPromoted)
+                   ({ T15323.hs:6:36 }
+                    (Unqual
+                     {OccName: v}))))))))]))
+          (PrefixCon
+           [])
+          ({ T15323.hs:6:42-55 }
+           (HsAppTy
+            (NoExt)
+            ({ T15323.hs:6:42-53 }
+             (HsTyVar
+              (NoExt)
+              (NotPromoted)
+              ({ T15323.hs:6:42-53 }
+               (Unqual
+                {OccName: MaybeDefault}))))
+            ({ T15323.hs:6:55 }
+             (HsTyVar
+              (NoExt)
+              (NotPromoted)
+              ({ T15323.hs:6:55 }
+               (Unqual
+                {OccName: v}))))))
+          (Nothing)))]
+       ({ <no location info> }
+        [])))))]
+  (Nothing)
+  (Nothing)))
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index ab0a393..1fd8c69 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -116,3 +116,4 @@ test('T14189',     normal, compile, ['-dsuppress-uniques -ddump-rn-ast'])
 test('T13986', normal, compile, [''])
 test('T10855', normal, compile, [''])
 test('T15139', normal, compile, ['-Wincomplete-patterns -fdiagnostics-show-caret'])
+test('T15323', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast'])



More information about the ghc-commits mailing list