Opened 3 years ago

Closed 3 years ago

#5409 closed bug (fixed)

Language.Haskell.TH.Syntax.tupleDataName wrong for unit

Reported by: NeilMitchell Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.1
Keywords: Cc: ndmitchell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

tupleDataName 0 generates the name GHC.Tuple.(), but that's wrong, it should be GHC.Unit.() (even worse, the source code actually has -- XXX Should it be GHC.Unit for 0 commas? - which is a correct observation)

Change History (1)

comment:1 Changed 3 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed

Good point. Fixed by

commit 0923cdc6ba600e67987f88c67ca80bf2d7a05400
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Wed Aug 17 07:58:36 2011 +0100

    The unit tuple is defined in a different module to other tuples (oddly)
    
    Fixes Trac #5409

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

 Language/Haskell/TH/Syntax.hs |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Language/Haskell/TH/Syntax.hs b/Language/Haskell/TH/Syntax.hs index 18f6029..31e1300 100644
--- a/Language/Haskell/TH/Syntax.hs
+++ b/Language/Haskell/TH/Syntax.hs
@@ -582,8 +582,9 @@ mk_tup_name n_commas space
   = Name occ (NameG space (mkPkgName "ghc-prim") tup_mod)
   where
     occ = mkOccName ('(' : replicate n_commas ',' ++ ")")
-    -- XXX Should it be GHC.Unit for 0 commas?
-    tup_mod = mkModName "GHC.Tuple"
+    tup_mod | n_commas ==0 = mkModName "GHC.Unit"
+            | otherwise    = mkModName "GHC.Tuple"
+    -- Oddly () is in a different module than the other tuples

I don't understand why () is in a different module though!

Simon

Note: See TracTickets for help on using tickets.