Ticket #7016 (closed bug: invalid)

Opened 12 months ago

Last modified 12 months ago

Declarations after top-level splice are ignored

Reported by: Oblosys Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.4.2
Keywords: Cc:
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: GHC rejects valid program Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Declarations that appear after a top-level splice seem to be ignored without any warning. In the attached Main, the identifier afterSplice is not recognized:

Main.hs:6:11: Not in scope: `afterSplice' 

The error disappears if the declaration of afterSplice is put before dummySplice, or if the declaration for problem is removed (in which case afterSplice is declared correctly, as can be seen with in ghci.)

I could track the problem back to at least ghc-7.0.4.

Attachments

Main.hs Download (164 bytes) - added by Oblosys 12 months ago.
TH.hs Download (121 bytes) - added by Oblosys 12 months ago.

Change History

Changed 12 months ago by Oblosys

Changed 12 months ago by Oblosys

Changed 12 months ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to invalid

This is by design, as described in Section 7.2 of the original  Template Haskell paper.

I agree it's not ideal, but it's not accidental, and I don't know of a better way.

Hmm. It may be that some of the changes mooted in my  New directions for Template Haskell post (which I plan to work in on August) may change this.

Simon

Changed 12 months ago by Oblosys

Ah, so it's a feature! :-) Perhaps this could be briefly mentioned in the documentation? (right after the quieter and less intimidating example). I thought it was a bug because I couldn't find it there and the error message didn't mention Template Haskell.

It's just a small issue, but since I use TH to derive type classes for data declarations, the most appropriate place for the splice would be close to the data declaration. (Each data type is also accompanied by a function declaration, which causes the scoping issues.)

I will await the changes from the new directions post!

-- Martijn

Note: See TracTickets for help on using tickets.