|
GHC mutual recursion weirdness: msg#00045lang.haskell.glasgow.bugs
Someone in #Haskell mentioned a problem they were having with GHC 6.4 and mutually recursive modules. I'd never tried them, so I tried the simplest thing I could think of and tried doing it a few ways, and these are my findings. I've attached all the relevant files and a tarball for maximum convenience. I wrote a really, really stupid pair of mutually recursive even and odd functions and stuck them in modules named Even and Odd. To break the cycle, I wrote a .hs-boot file for the Even module which gave a type signature for the even function. First, I tried it with GHCi. Even worked fine: Prelude> :l Even Compiling Even[boot] ( Even.hs-boot, Even.o-boot ) Compiling Odd ( ./Odd.hs, interpreted ) Compiling Even ( Even.hs, interpreted ) Ok, modules loaded: Even, Odd, Even. *Even> even 1 False Odd, however, did not: *Even> :l Odd Compiling Even[boot] ( Even.hs-boot, Even.o-boot ) Compiling Odd ( Odd.hs, interpreted ) Ok, modules loaded: Odd, Even. *Odd> odd 1 *** Exception: expectJust upsweep_mod:old_linkable If I were less suspicious (and didn't know for a fact that odd actually used code from even), I might have thought everything was fine, until I tried to run it. But then I get this weird error. ghc --make has similar behaviour, which is not terribly interesting because it doesn't link unless you run it on a Main module, so I made two Main modules, EvenMain and OddMain... ghc --make EvenMain works fine, but ghc --make OddMain does not (even without deleting the .o/.hi files between): % ghc --make OddMain.hs Chasing modules from: OddMain.hs Compiling Even[boot] ( ./Even.hs-boot, ./Even.o-boot ) Skipping Odd ( ./Odd.hs, ./Odd.o ) Compiling Main ( OddMain.hs, OddMain.o ) Linking ... ghc-6.4: panic! (the `impossible' happened, GHC version 6.4): expectJust upsweep_mod:old_linkable Please report it as a compiler bug to glasgow-haskell-bugs@xxxxxxxxxxx, or http://sourceforge.net/projects/ghc/. Hmm, and to think I almost sent this to haskell@xxxxxxxxxxxx Anyway, there you have it. -- Sam
Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@xxxxxxxxxxx http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | ghc-6.2.1 panics while compiling darcs 1.0.3-rc1, Louai Khanji |
|---|---|
| Next by Date: | RE: runghc exit status, Simon Marlow |
| Previous by Thread: | ghc-6.2.1 panics while compiling darcs 1.0.3-rc1, Louai Khanji |
| Next by Thread: | Re: GHC mutual recursion weirdness, Samuel Bronson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |