haste-compiler icon indicating copy to clipboard operation
haste-compiler copied to clipboard

compiler bug involving MVar, Integer, and tuples

Open blynn opened this issue 8 years ago • 0 comments

The following generates JavaScript that crashes due to an Uncaught ReferenceError involving what seems to be a generated symbol (e.g. "_l2"). It succeeds if compiled with --ddisable-js-opts.

import Control.Concurrent.MVar
import Data.Array

main :: IO ()
main = do
  let r = ((0,0), (7,7))
  mv <- newEmptyMVar
  putMVar mv True
  b <- takeMVar mv
  if b then do
    putStrLn "crashes here"
    putStrLn $ show [inRange r (0 + x, 7 + y) | x <- [-1, 1], y <- [-1, 1]]
    putStrLn "...unless compiled with --ddisable-js-opts"
  else undefined

I tried finding a smaller example, but I found the crash disappeared if:

  • The Integer values are declared as Ints instead: (0 :: Int,0 :: Int), (7,7))
  • The MVar is removed
  • The 2-dimensional bounds are replaced with a 1-dimensional bound, e.g. (0, 7)

Hopefully the above is enough to go on.

blynn avatar Sep 24 '17 05:09 blynn