($) of an unboxed double appears to be treated as 0.0
The following program compiles cleanly with GHC 7.0.3 running on a 64 bit Linux machine, but produces the wrong answer:
$ uname -a
Linux pandora 2.6.32-5-amd64 #1 SMP Fri Sep 9 20:23:16 UTC 2011 x86_64 GNU/Linux
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.3
$ cat bug.hs
{-# LANGUAGE MagicHash #-}
import GHC.Exts
main :: IO ()
main = print $ D# $ 3.0##
$ ghc -Wall bug.hs
[1 of 1] Compiling Main ( bug.hs, bug.o )
Linking bug ...
$ ./bug
0.0
The expected behavior was to either produce a compile-time error message or to output 3.0.
Compiling this program on the same machine with -dcore-lint
produces:
$ ghc bug.hs -dcore-lint
[1 of 1] Compiling Main ( bug.hs, bug.o )
*** Core Lint errors : in result of Desugar ***
<no location info>:
In the expression: GHC.Base.$ @ GHC.Prim.Double#
Kinds don't match in type application:
Type variable: a_ahX :: *
Arg type: GHC.Prim.Double# :: #
*** Offending Program ***
Main.main :: GHC.Types.IO ()
[LclIdX]
Main.main =
GHC.Base.$
@ GHC.Types.Double
@ (GHC.Types.IO ())
(System.IO.print @ GHC.Types.Double GHC.Float.$fShowDouble)
(GHC.Base.$ @ GHC.Prim.Double# @ GHC.Types.Double GHC.Types.D# 3.0)
:Main.main :: GHC.Types.IO ()
[LclIdX]
:Main.main = GHC.TopHandler.runMainIO @ () Main.main
*** End of Offense ***
<no location info>:
Compilation had errors
Compiling the program with GHC 6.12.1 on a different machine running 32 bit Linux fails with the following perfectly reasonable error message:
$ uname -a
Linux golconda 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.1
$ ghc bug.hs
bug.hs:6:15:
Couldn't match kind `#' against `*'
When matching the kinds of `Double# :: #' and `a :: *'
Expected type: a
Inferred type: Double#
In the first argument of `($)', namely `D#'
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | axch@mit.edu |
Operating system | |
Architecture |