Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,402
    • Issues 5,402
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 595
    • Merge requests 595
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #5375
Closed
Open
Issue created Aug 04, 2011 by reinerp@trac-reinerp

Regression in newName

Template Haskell's newName no longer works properly, with GHC HEAD. Consider:

{-# LANGUAGE TemplateHaskell #-}

module B where

import Language.Haskell.TH

data D = D

-- declare 'data E = D' with a fresh name 'D'
$(do
    nm <- newName "D"
    return $ [DataD [] (mkName "E") [] [NormalC nm []] []]
 )

With ghc-7.0.3, this compiles without error, as it should. However, with ghc-7.3.20110803, we get:

B.hs:8:3:
    Multiple declarations of `D'
    Declared at: B.hs:7:10
                 B.hs:8:3

which is wrong.

The following might also be related. Given:

{-# LANGUAGE TemplateHaskell #-}

module C where

import Language.Haskell.TH

g = $(do 
        nm <- newName "f"
        return $ VarE nm
     )

with ghc-7.0.3 we get the correct error message

C.hs:7:7:
    Not in scope: `f[aK5]'
    In the result of the splice:
      $(do { nm <- newName "f";
               return $ VarE nm })
    To see what the splice expanded to, use -ddump-splices
    In the expression:
      $(do { nm <- newName "f";
               return $ VarE nm })
    In an equation for `g':
        g = $(do { nm <- newName "f";
                     return $ VarE nm })

but with ghc-7.3.20110803 we get a GHC internal error message:

C.hs:7:7:
    GHC internal error: `f_aOw' is not in scope during type checking, but it passed the renamer
    tcg_type_env of environment: []
    tcl_env of environment: [(rgQ, Identifier[g::t_a, 1])]
    In the expression: f_aOw
    In the result of the splice:
      $(do { nm <- newName "f";
             return $ VarE nm })
    To see what the splice expanded to, use -ddump-splices
    In the expression:
      $(do { nm <- newName "f";
             return $ VarE nm })
Trac metadata
Trac field Value
Version 7.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking