Skip to content

GHC 8.4.1 bug: -O + separate compilation + three list fields + concatenation; core-lint fails

A simple program that works in 8.2.1 fails in 8.4.1 when compiled with -O. (Sorry, haven't tested 8.2.2.) GHC with -dcore-lint reports an error.

See attached files. In one file I declared:

module Sep where

data Sep = Sep
  { bugVanishesWithoutThis :: [()]
  , middle :: [String]
  , orThis :: [()]
  }

catSep :: Sep -> Sep -> Sep
catSep (Sep a b c) (Sep x y z) = Sep (a ++ x) (b ++ y) (c ++ z)

cc :: Sep -> Bool
cc boost = elem "foo" $ middle boost

and in a second file, simple code fails when compiled with -O:

module Main (main) where

import Sep

main :: IO ()
main = print $ cc bb

bb :: Sep
bb = catSep b1 b2

b1 :: Sep
b1 = Sep [] ["foo"] []

b2 :: Sep
b2 = Sep [] ["bar"] []

This should print "True", and does so for GHC 8.2.1, and GHC 8.4.1 without -O, but prints "False" for GHC 8.4.1 with -O.

I was unable to reproduce the bug with a single file.

Trac metadata
Trac field Value
Version 8.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ben@dfinity.org
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information