Ticket #5379 (closed bug: fixed)

Opened 22 months ago

Last modified 22 months ago

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 Difficulty:
Test Case: th/T5379 Blocked By:
Blocking: Related Tickets:

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

Changed 22 months ago by simonpj@…

commit 46c19a89d410910bc224a4a8566e506e52b36e43

Author: Simon Peyton Jones <simonpj@microsoft.com>
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(-)

Changed 22 months ago by simonpj

  • status changed from new to merge
  • testcase set to th/T5379

Fixed.

Changed 22 months ago by igloo

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

Merged as changeset:4081406d0ca013736fbdbe070a94b2922e8e3fe5

Note: See TracTickets for help on using tickets.