[commit: ghc] master: Fix ASSERT in buildPatSyn, and T10897 test (7824870)

git at git.haskell.org git at git.haskell.org
Wed Dec 23 10:13:18 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/78248702b0b8189d73f08c89d86f5cb7a3c6ae8c/ghc

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

commit 78248702b0b8189d73f08c89d86f5cb7a3c6ae8c
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Dec 23 10:13:26 2015 +0000

    Fix ASSERT in buildPatSyn, and T10897 test
    
    This closes Trac #10897


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

78248702b0b8189d73f08c89d86f5cb7a3c6ae8c
 compiler/iface/BuildTyCl.hs                              | 16 ++++++++++------
 .../patsyn/should_compile/{T10897b.hs => T10897.hs}      |  2 +-
 testsuite/tests/patsyn/should_compile/all.T              |  4 ++--
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/compiler/iface/BuildTyCl.hs b/compiler/iface/BuildTyCl.hs
index 7c62bc2..d370d37 100644
--- a/compiler/iface/BuildTyCl.hs
+++ b/compiler/iface/BuildTyCl.hs
@@ -182,12 +182,14 @@ buildPatSyn :: Name -> Bool
 buildPatSyn src_name declared_infix matcher@(matcher_id,_) builder
             (univ_tvs, req_theta) (ex_tvs, prov_theta) arg_tys
             pat_ty field_labels
-  = ASSERT2((and [ univ_tvs == univ_tvs1
-                 , ex_tvs == ex_tvs1
-                 , pat_ty `eqType` pat_ty1
-                 , prov_theta `eqTypes` prov_theta1
-                 , req_theta `eqTypes` req_theta1
-                 , arg_tys `eqTypes` arg_tys1
+  = -- The assertion checks that the matcher is
+    -- compatible with the pattern synonym
+    ASSERT2((and [ univ_tvs `equalLength` univ_tvs1
+                 , ex_tvs `equalLength` ex_tvs1
+                 , pat_ty `eqType` substTy subst pat_ty1
+                 , prov_theta `eqTypes` substTys subst prov_theta1
+                 , req_theta `eqTypes` substTys subst req_theta1
+                 , arg_tys `eqTypes` substTys subst arg_tys1
                  ])
             , (vcat [ ppr univ_tvs <+> twiddle <+> ppr univ_tvs1
                     , ppr ex_tvs <+> twiddle <+> ppr ex_tvs1
@@ -205,6 +207,8 @@ buildPatSyn src_name declared_infix matcher@(matcher_id,_) builder
     (ex_tvs1, prov_theta1, cont_tau) = tcSplitSigmaTy cont_sigma
     (arg_tys1, _) = tcSplitFunTys cont_tau
     twiddle = char '~'
+    subst = zipTopTCvSubst (univ_tvs1 ++ ex_tvs1)
+                           (mkTyVarTys (univ_tvs ++ ex_tvs))
 
 ------------------------------------------------------
 type TcMethInfo = (Name, Type, Maybe (DefMethSpec Type))
diff --git a/testsuite/tests/patsyn/should_compile/T10897b.hs b/testsuite/tests/patsyn/should_compile/T10897.hs
similarity index 61%
rename from testsuite/tests/patsyn/should_compile/T10897b.hs
rename to testsuite/tests/patsyn/should_compile/T10897.hs
index 6b506b8..e34f146 100644
--- a/testsuite/tests/patsyn/should_compile/T10897b.hs
+++ b/testsuite/tests/patsyn/should_compile/T10897.hs
@@ -1,4 +1,4 @@
-module B where
+module T10897 where
 import T10897a
 
 Single y = True
diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T
index dd2bbf4..e1c8243 100644
--- a/testsuite/tests/patsyn/should_compile/all.T
+++ b/testsuite/tests/patsyn/should_compile/all.T
@@ -41,8 +41,8 @@ test('poly-export3', normal, compile, [''])
 test('multi-export', normal, compile, [''])
 test('export-super-class', normal, compile, [''])
 test('export-record-selector', normal, compile, [''])
-test('T10897', expect_broken(10897), multi_compile, ['T10897', [
+test('T10897', normal, multi_compile, ['T10897', [
                                        ('T10897a.hs','-c')
-                                      ,('T10897b.hs', '-c')], ''])
+                                      ], '-v0'])
 test('T11224b', normal, compile, [''])
 test('MoreEx', normal, compile, [''])



More information about the ghc-commits mailing list