[commit: ghc] master: Fix hs-boot knot-tying with record wild cards. (9e9fb57)

git at git.haskell.org git at git.haskell.org
Sat Jul 29 14:34:39 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9e9fb57c37c62bb6c90f15b173c5d3632121c66a/ghc

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

commit 9e9fb57c37c62bb6c90f15b173c5d3632121c66a
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Fri Jul 28 18:25:12 2017 -0400

    Fix hs-boot knot-tying with record wild cards.
    
    Fixes #13710.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate
    
    Reviewers: bgamari, austin, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: simonpj, rwbarton, thomie
    
    GHC Trac Issues: #13710
    
    Differential Revision: https://phabricator.haskell.org/D3743


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

9e9fb57c37c62bb6c90f15b173c5d3632121c66a
 compiler/iface/TcIface.hs                                | 9 ++++++++-
 testsuite/tests/driver/T13710/A.hs                       | 5 +++++
 testsuite/tests/driver/T13710/A.hs-boot                  | 2 ++
 testsuite/tests/{programs/hs-boot => driver/T13710}/B.hs | 4 +---
 testsuite/tests/{cabal/pkg02 => driver/T13710}/Makefile  | 2 ++
 testsuite/tests/driver/T13710/T13710.stdout              | 3 +++
 testsuite/tests/driver/T13710/all.T                      | 4 ++++
 7 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/compiler/iface/TcIface.hs b/compiler/iface/TcIface.hs
index b3119b2..9e06165 100644
--- a/compiler/iface/TcIface.hs
+++ b/compiler/iface/TcIface.hs
@@ -915,7 +915,14 @@ tcIfaceDataCons tycon_name tycon tc_tybinders if_cons
         ; ~(eq_spec, theta, arg_tys, stricts) <- forkM (mk_doc dc_name) $
              do { eq_spec <- tcIfaceEqSpec spec
                 ; theta   <- tcIfaceCtxt ctxt
-                ; arg_tys <- mapM tcIfaceType args
+                -- This fixes #13710.  The enclosing lazy thunk gets
+                -- forced when typechecking record wildcard pattern
+                -- matching (it's not completely clear why this
+                -- tuple is needed), which causes trouble if one of
+                -- the argument types was recursively defined.
+                -- See also Note [Tying the knot]
+                ; arg_tys <- forkM (mk_doc dc_name <+> text "arg_tys")
+                           $ mapM tcIfaceType args
                 ; stricts <- mapM tc_strict if_stricts
                         -- The IfBang field can mention
                         -- the type itself; hence inside forkM
diff --git a/testsuite/tests/driver/T13710/A.hs b/testsuite/tests/driver/T13710/A.hs
new file mode 100644
index 0000000..5181945
--- /dev/null
+++ b/testsuite/tests/driver/T13710/A.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE RecordWildCards #-}
+module A where
+import B
+data E = MkE
+p (H{..}) = ()
diff --git a/testsuite/tests/driver/T13710/A.hs-boot b/testsuite/tests/driver/T13710/A.hs-boot
new file mode 100644
index 0000000..94a2f5e
--- /dev/null
+++ b/testsuite/tests/driver/T13710/A.hs-boot
@@ -0,0 +1,2 @@
+module A ( E ) where
+data E
diff --git a/testsuite/tests/programs/hs-boot/B.hs b/testsuite/tests/driver/T13710/B.hs
similarity index 63%
copy from testsuite/tests/programs/hs-boot/B.hs
copy to testsuite/tests/driver/T13710/B.hs
index 13d1ac4..87c93a9 100644
--- a/testsuite/tests/programs/hs-boot/B.hs
+++ b/testsuite/tests/driver/T13710/B.hs
@@ -1,5 +1,3 @@
-
 module B where
-
-import C
 import {-# SOURCE #-} A
+data H = H { h :: E }
diff --git a/testsuite/tests/cabal/pkg02/Makefile b/testsuite/tests/driver/T13710/Makefile
similarity index 59%
copy from testsuite/tests/cabal/pkg02/Makefile
copy to testsuite/tests/driver/T13710/Makefile
index 4a26853..d582f94 100644
--- a/testsuite/tests/cabal/pkg02/Makefile
+++ b/testsuite/tests/driver/T13710/Makefile
@@ -2,3 +2,5 @@ TOP=../../..
 include $(TOP)/mk/boilerplate.mk
 include $(TOP)/mk/test.mk
 
+T13710:
+	'$(TEST_HC)' $(TEST_HC_OPTS) --make B.hs
diff --git a/testsuite/tests/driver/T13710/T13710.stdout b/testsuite/tests/driver/T13710/T13710.stdout
new file mode 100644
index 0000000..2d72928
--- /dev/null
+++ b/testsuite/tests/driver/T13710/T13710.stdout
@@ -0,0 +1,3 @@
+[1 of 3] Compiling A[boot]          ( A.hs-boot, A.o-boot )
+[2 of 3] Compiling B                ( B.hs, B.o )
+[3 of 3] Compiling A                ( A.hs, A.o )
diff --git a/testsuite/tests/driver/T13710/all.T b/testsuite/tests/driver/T13710/all.T
new file mode 100644
index 0000000..64daacc
--- /dev/null
+++ b/testsuite/tests/driver/T13710/all.T
@@ -0,0 +1,4 @@
+test('T13710',
+     [extra_files(['A.hs', 'A.hs-boot', 'B.hs'])],
+     run_command,
+     ['$MAKE -s --no-print-directory T13710'])



More information about the ghc-commits mailing list