Ticket #2631 (closed bug: duplicate)

Opened 5 years ago

Last modified 5 years ago

Template Haskell weird error message

Reported by: NeilMitchell Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 6.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I've noticed quite a few bugs related to weird TemplateHaskell expressions crashing the compiler recently, so I thought I'd try and write a nice exhaustive test of []'s in all possible places. In doing so however, I got some fairly weird error messages:

C:\Neil\temp>cat Main.hs
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Language.Haskell.TH
main _ = $( return $ CompE [])
C:\Neil\temp>ghci Main.hs
GHCi, version 6.9.20080916: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( Main.hs, interpreted )
Loading package syb ... linking ... done.
Loading package array-0.1 ... linking ... done.
Loading package packedstring-0.1 ... linking ... done.
Loading package containers-0.1 ... linking ... done.
Loading package pretty-1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Ok, modules loaded: Main.
*Main> main ()

<interactive>:1:0:
    Can't find interface-file declaration for variable main
      Probable cause: bug in .hi-boot file, or inconsistent .hi file
      Use -ddump-if-trace to get an idea of which file caused the error
    In the expression: main ()
    In the definition of `it': it = main ()
*Main> :q
Leaving GHCi.

C:\Neil\temp>ghc --make Main.hs
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.1 ... linking ... done.
Loading package packedstring-0.1 ... linking ... done.
Loading package containers-0.1 ... linking ... done.
Loading package pretty-1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Linking Main.exe ...
Main.o:fake:(.text+0x4d): undefined reference to `Main_main_closure'
Main.o:fake:(.data+0x4): undefined reference to `Main_main_closure'
collect2: ld returned 1 exit status

The main binding seems to get dropped, but no warning is issued. Later on, when the main binding is needed, it can't be found.

-- Neil

Change History

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonpj

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

Happily this is a different manifestation of #2597, and already fixed. The error message is now

T2631.hs:4:12:
    Empty stmt list in do-block
    When splicing generated code into the program
    When splicing TH expression: CompE []
    In the expression: $(return $ CompE [])
    In the definition of `main': main _ = $(return $ CompE [])

Simon

Note: See TracTickets for help on using tickets.