GHC and iserv cannot agree on what an Integer is; insanity ensues
Tested off ghc-8.6.1-alpha1, running on macOS 10.13.5.
-
Compile a GHC that uses
integer-gmp. -
Compile a GHC that uses
integer-simple. -
Make
Main.hs:{-# LANGUAGE TemplateHaskell #-} main = print $([e| 0 |]) -
Try to compile the file with
integer-gmpghcandinteger-simpleghc-iserv.-
Expected behavior: (compiles fine and executable prints
0) or (outputs to-the-point error message) -
Actual:
[1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:2:14: error: • Exception when trying to run compile-time code: ghc: ghc-iserv terminated (-11) Code: [| 0 |] • In the untyped splice: $([| 0 |]) | 2 | main = print $([e| 0 |]) | ^^^^^^^^^^^
-
-
Try to compile the file with
integer-simpleghcandinteger-gmpghc-iserv.-
Expected behavior: (compiles fine and executable prints
0) or (outputs to-the-point error message) -
Actual:
[1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:2:14: error: • Exception when trying to run compile-time code: heap overflow Code: [| 0 |] • In the untyped splice: $([| 0 |]) | 2 | main = print $([e| 0 |]) | ^^^^^^^^^^^
-
For more fun, replace the 0 with a 1. gmp ghc + simple iserv continues to explode. This is better than simple ghc + gmp iserv:
$ ./Main
283468057265
$ ./Main
283468057265
$ $simple_ghc -fexternal-interpreter -pgmi=$gmp_iserv Main.hs # again
# ...
$ ./Main
283468057105
Absolutely delicious. There is a similar situation for fractional literals.
It would be nice if there were at least a warning for situations like this.