logo       

[ ghc-Bugs-1068519 ] Template Haskell: Crash when using newName: msg#00015

lang.haskell.glasgow.bugs

Subject: [ ghc-Bugs-1068519 ] Template Haskell: Crash when using newName

Bugs item #1068519, was opened at 2004-11-18 08:45
Message generated for change (Comment added) made by simonpj
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1068519&group_id=8032

Category: Template Haskell
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Stefan Heimann (stefanheimann)
Assigned to: Simon Peyton Jones (simonpj)
Summary: Template Haskell: Crash when using newName

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Simon Peyton Jones (simonpj)
Date: 2004-12-02 17:20

Message:
Logged In: YES
user_id=50165

Thanks for this report. I've commited a fix.

Simon

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1068519&group_id=8032


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise