[GHC] #9562: Type families + hs-boot files = unsafeCoerce
GHC
ghc-devs at haskell.org
Fri May 1 19:01:05 UTC 2015
#9562: Type families + hs-boot files = unsafeCoerce
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: ezyang
Type: bug | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 7.8.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC accepts | Unknown/Multiple
invalid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #10270 | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by ezyang):
> There does not seem to be a way to feed GHC a list of object files to
link together and coax it to skip linking
Actually, this is not true:
{{{
ezyang at sabre:~$ ghc -c A.hs
ezyang at sabre:~$ ghc -c B.hs-boot
ezyang at sabre:~$ ghc -c C.hs
ezyang at sabre:~$ ghc -c B.hs
ezyang at sabre:~$ ghc -c D.hs
ezyang at sabre:~$ ghc -c Main.hs
ezyang at sabre:~$ ghc Main.o A.o B.o C.o D.o -o Unsafe
ezyang at sabre:~$ ./Unsafe
-5692549928996289131
}}}
Unfortunately, GHC has no idea about the dependency structure of the
object files; for all it knows, it could have been produced by another
compiler. So there actually is no way for GHC to figure out that `B.o` is
type-unsafe in this case. This would imply the only way to safely link
Haskell objects is to use `ghc Main.hs` (which will do dependency
resolution.)
Note that Richard's original proposed fix will work in this case, since
`B.hs` will be refused as `B.hs-boot` doesn't report enough type families.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9562#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list