Consider the following trivial modules:
module Fail1 where
identity x = x
module Main where
import Fail1
main = print (identity 7)
I save these as Fail1.hs and Fail2.hs. If I try to run this program, all is well:
> runhaskell Fail2
7
But take a look at this:
> ghc -O2 --make Fail1
[1 of 1] Compiling Fail1 ( Fail1.hs, Fail1.o )
> runhaskell Fail2
_
The program now hangs forever, with ghc.exe consuming 100% of one CPU core. What the heck?
It gets better though:
> ghc -O2 --make Fail2
[2 of 2] Compiling Main ( Fail2.hs, Fail2.o )
> runhaskell Fail2
Access violation in generated code when reading 0xffffffffffffffff
Attempting to reconstruct a stack trace...
Frame Code address
* 0x71fdd90 0x3d7ce28 C:\Program Files\Haskell Platform\8.6.3\bin\ghc.exe+0x397ce28
Er... wat?
Ironically, if I just run Fail2.exe itself, it works perfectly:
> Fail2
7
What in the heck is going on? Am I going mad? This really, really looks like some kind of GHC bug. Can anyone else reproduce this, or is it just my system?
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.3
(Wow, OK. That really doesn't display much info. I'm running Windows 7 Pro 64-bit, and I believe I've installed the 64-bit build of GHC.)
runhaskell Fail2andrunhaskell Fail2.hs? Once you've built aFail2executable,runhaskellmight be trying to interpret it as a Haskell source file.Fail2:1:1: error: lexical error at character '\DEL'followed by some binary garbage. I think @user11228628 's guess is pretty accurate.