Ticket #3600 (closed merge: fixed)

Opened 4 years ago

Last modified 4 years ago

Template Haskell mis-coverting empty list to empty string

Reported by: simonpj Owned by: igloo
Priority: normal Milestone: 6.12.1
Component: Template Haskell Version: 6.10.4
Keywords: Cc: aslatter@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: th/T3600 Blocked By:
Blocking: Related Tickets:

Description

Antoine Latter aslatter@… writes: the program Demo.hs compiles on 6.10, but not on 6.12rc1. The output --ddump-splices for 6.10:

Demo.hs:1:0:
   Demo.hs:1:0: Splicing declarations
       test
     ======>
       Demo.hs:6:2-5
       myFunction[aLQ] = Demo2.testFun []
Ok, modules loaded: Demo2, Main.

In 6.12rc1:

Demo.hs:1:0:
    Demo.hs:1:0: Splicing declarations
        test
      ======>
        Demo.hs:6:2-5
        myFunction[aNX] = testFun ""

Demo.hs:6:2:
    Couldn't match expected type `[Char]' against inferred type `Char'
      Expected type: [String]
      Inferred type: [Char]
    In the first argument of `testFun', namely `""'
    In the expression: testFun ""
Failed, modules loaded: Demo2.

The code is short:

---------- Demo.hs ---------------
{-# LANGUAGE TemplateHaskell #-}
module Demo where
import Demo2
$(test)

---------- Demo2.hs ---------------
{-# LANGUAGE TemplateHaskell #-}
module Demo2 where

import Language.Haskell.TH

test :: Q [Dec]
test = do
     let args = [] :: [String]
         body = [| testFun args |]
     decNm <- newName "myFunction"
     (:[]) `fmap` funD decNm [clause [] (normalB body) []]

testFun :: [String] -> String
testFun _ = "hello"

Change History

Changed 4 years ago by simonpj

  • cc aslatter@… added
  • owner set to igloo
  • type changed from bug to merge
  • testcase set to th/T3600

Fixed by

Tue Oct 20 00:26:16 PDT 2009  simonpj@microsoft.com
  * Fix Trac #3600: Template Haskell bug in Convert
  
  This bug was introduced when I added an optimisation, described in
  Note [Converting strings] in Convert.lhs.  It was treating *all*
  empty lists as strings, not just string-typed ones!
  
  The fix is easy.  Pls MERGE to stable branch.
  

    M ./compiler/hsSyn/Convert.lhs -4 +10

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged.

Note: See TracTickets for help on using tickets.