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,242
    • Issues 5,242
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 568
    • Merge requests 568
  • 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
  • #275
Closed
Open
Issue created Nov 18, 2004 by stefanheimann@trac-stefanheimann

Template Haskell: Crash when using newName

GHC/Template Haskell has problems when newName is used
for generating a name for a label of an algebraic
datatype. The example attached consists of a
compile-time function 'recordLabel', it is invoked like
this

$(recordLabel "foo" [t| Int |])

and should produce something like

data Foo = { fooVal_Unique :: Int }
foo r = fooVal_Unique r

(the reason for defining foo as a separate function is
that there is some more code involved in the real
application).

'recordLabel' generates the name of the datatype and
the name of the toplevel access function (Foo and foo
in the example above) from the string argument given.
But fooVal_Unique should be a new name that does not
match any existing name and so I want to use 'newName'
for generating it.

Actually, there are two different problems when using
newName:

When you do 'newName "foo"' than GHC complains about an
ambiguous occurrence `foo'. When you do something like
'newName "_foo"', GHC crashes. There is a better
explanation of the two problems in the source file
Template.hs I attached to this bug report.

I have tested the bug against the precompiled
development snapshot ghc-6.3.20041116 for Linux. Please
note that I had some problems getting the development
snapshot running, because it seems to use a wrong path
to the assembler and so I needed to pass the path to
the assembler with the -pgma flag. Check the file
compile.sh. However, the bug also occurs with
ghc-6.3.20041116.

The example attached contains the files Template.hs,
Test.hs and compile.sh. Template.hs defines the
function recordLabel, Test.hs calls recordLabel and
compile.sh is a small script for invoking GHC.
Trac metadata
Trac field Value
Version None
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
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