[commit: ghc] master: Fix #14692 by correcting an off-by-one error in TcGenDeriv (0074a08)

git at git.haskell.org git at git.haskell.org
Mon Jan 22 01:39:44 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/0074a08ea9dfd1416aa57a9504be73dcdf7a1e2b/ghc

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

commit 0074a08ea9dfd1416aa57a9504be73dcdf7a1e2b
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sun Jan 21 12:06:06 2018 -0500

    Fix #14692 by correcting an off-by-one error in TcGenDeriv
    
    A silly mistake in `gen_Show_binds` was causing derived
    `Show` instances for empty data types to case on the precedence
    argument instead of the actual value being showed.
    
    Test Plan: make test TEST=drv-empty-data
    
    Reviewers: bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #14692
    
    Differential Revision: https://phabricator.haskell.org/D4328


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

0074a08ea9dfd1416aa57a9504be73dcdf7a1e2b
 compiler/typecheck/TcGenDeriv.hs                              | 2 +-
 testsuite/tests/deriving/should_compile/drv-empty-data.stderr | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcGenDeriv.hs b/compiler/typecheck/TcGenDeriv.hs
index b2d45fd..1ac3505 100644
--- a/compiler/typecheck/TcGenDeriv.hs
+++ b/compiler/typecheck/TcGenDeriv.hs
@@ -1132,7 +1132,7 @@ gen_Show_binds get_fixity loc tycon
   = (unitBag shows_prec, emptyBag)
   where
     data_cons = tyConDataCons tycon
-    shows_prec = mkFunBindEC 1 loc showsPrec_RDR id (map pats_etc data_cons)
+    shows_prec = mkFunBindEC 2 loc showsPrec_RDR id (map pats_etc data_cons)
     comma_space = nlHsVar showCommaSpace_RDR
 
     pats_etc data_con
diff --git a/testsuite/tests/deriving/should_compile/drv-empty-data.stderr b/testsuite/tests/deriving/should_compile/drv-empty-data.stderr
index e131c1c..5baf6a6 100644
--- a/testsuite/tests/deriving/should_compile/drv-empty-data.stderr
+++ b/testsuite/tests/deriving/should_compile/drv-empty-data.stderr
@@ -7,7 +7,7 @@ Derived class instances:
     GHC.Read.readListPrec = GHC.Read.readListPrecDefault
   
   instance GHC.Show.Show (DrvEmptyData.Void a) where
-    GHC.Show.showsPrec z = case z of
+    GHC.Show.showsPrec _ z = case z of
   
   instance GHC.Classes.Ord (DrvEmptyData.Void a) where
     GHC.Classes.compare _ z = GHC.Types.EQ



More information about the ghc-commits mailing list