Opened 4 years ago

Closed 4 years ago

#5379 closed bug (fixed)

Scoping error in Template Haskell antiquotations

Reported by: reinerp Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: th/T5379
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Related to #5375, #5037. When compiling and running the following:

{-# LANGUAGE TemplateHaskell #-}

import Language.Haskell.TH

$( [d| g = 0
       h = $( return $ LamE [VarP (mkName "g")] (VarE 'g) ) |] )

main = print (h 1)

the splice should be

g' = 0
h = \g -> g'

and so the program should print 0 at runtime. Instead, it prints 1.

This is with both ghc-7.0.3 and ghc-7.3.20110803.

Change History (3)

comment:1 Changed 4 years ago by simonpj@…

commit 46c19a89d410910bc224a4a8566e506e52b36e43

Author: Simon Peyton Jones <[email protected]>
Date:   Fri Aug 5 15:29:44 2011 +0100

    Another run at binders in Template Haskell (fixes Trac #5379)
    
    TH quotation was using mkName rather than newName for
    top-level definitions, which is plain wrong as #5379
    points out.

 compiler/basicTypes/RdrName.lhs |    4 +-
 compiler/deSugar/DsMeta.hs      |   28 ++++---------------------
 compiler/hsSyn/Convert.lhs      |    9 ++++---
 compiler/iface/MkIface.lhs      |    2 +-
 compiler/rename/RnEnv.lhs       |   42 ++++++++++++++++++--------------------
 5 files changed, 33 insertions(+), 52 deletions(-)

comment:2 Changed 4 years ago by simonpj

  • Status changed from new to merge
  • Test Case set to th/T5379

Fixed.

comment:3 Changed 4 years ago by igloo

  • Resolution set to fixed
  • Status changed from merge to closed
Note: See TracTickets for help on using tickets.