id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
2386	Splicing in constructors that are abstract from the point of view of the splice point is unreliable	batterseapower		"Test1.hs:
{{{
{-# LANGUAGE TemplateHaskell #-}

module Main where

import Test2

main = putStrLn (show $(makeOne))
}}}

Test2.hs:
{{{
{-# LANGUAGE TemplateHaskell #-}

module Test2(ExportedAbstract, makeOne) where

data ExportedAbstract = Yay String | NonYay AnotherThing

data AnotherThing = Foo String

instance Show ExportedAbstract where
	show _ = ""Shown""

makeOne = [| Yay ""Yep"" |]
}}}

Compile this with optimizations:
{{{
ghc Test2.hs -O2
ghc --make Test1.hs
}}}

Results in:
{{{
$ ./Test1
Shown
}}}

Compile this without optimizations:
{{{
ghc Test2.hs -O0
ghc --make Test1.hs
}}}

Results in:
{{{
$ ghc --make Test1.hs
[2 of 2] Compiling Main             ( Test1.hs, Test1.o )
Loading package base ... linking ... done.
Loading package pretty-1.0.0.0 ... linking ... done.
Loading package array-0.1.0.0 ... linking ... done.
Loading package packedstring-0.1.0.0 ... linking ... done.
Loading package containers-0.1.0.1 ... linking ... done.
Loading package template-haskell ... linking ... done.

Test1.hs:7:24:
    Can't find interface-file declaration for data constructor Test2.Yay
      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 first argument of `show', namely `$makeOne'
    In the first argument of `putStrLn', namely `(show ($makeOne))'
    In the expression: putStrLn (show ($makeOne))
}}}

Why is this? Because trimThing in TidyPgm makes data types abstract in some circumstances, and it only happens if compiling a boot file or with -O0!

I think this program should compile as the splicing is not a violation of the abstractness of the data type: all the manipulation etc is still being done by the defining module."	merge	closed	normal	6.8 branch	Template Haskell	6.8.3	fixed			MacOS X	x86_64 (amd64)		Unknown	th/T2386			
