
My program was crashing and I couldn't figure out why. Then I discovered this strange bug involving classes, implicit parameters, and module interfaces (see enclosed files). Basically the type-checker is not being strict enough and misses this compile-time error. The workaround, of course, is not to make the error. module A where { class C a where { f :: (?p :: String) => a; }; instance C String where { f = ?p; }; g :: (?p :: String) => String; g = ?p; } {-- Compile using this: ghc -fglasgow-exts -c A.hs && ghc -fglasgow-exts A.o Main.hs -o bug && ./bug Bug won't happen with --make: rm bug; rm *.hi *.o; ghc -fglasgow-exts --make Main.hs -o bug && ./bug Bug won't happen if everything is in one module. --} module Main where { import A; main = putStrLn f; -- BUG: this compiles (and crashed when run, of course) -- main = putStrLn g; -- this correctly gives a compile-time error } $ ghc --version The Glorious Glasgow Haskell Compilation System, version 5.04 $ uname -a Darwin Ashley-Yakeleys-Computer.local. 6.2 Darwin Kernel Version 6.2: Tue Nov 5 22:00:03 PST 2002; root:xnu/xnu-344.12.2.obj~1/RELEASE_PPC Power Macintosh powerpc -- Ashley Yakeley, Seattle WA
participants (1)
-
Ashley Yakeley