Out of scope error with -fprefer-byte-code and breakpoints
Ticket related to #22955, extracted from Mercury's codebase.
Given two files:
A.hs
module A where
import B
foo :: Bool
foo = True
B.hs
module B where
class Eq a => C a where
get :: a
instance C Int where
get = let x = x in x
{-# INLINE get #-}
perform the following:
- Remove *.hi *.o files.
- Run
ghci -fprefer-byte-code -fbyte-code-and-object-code -dlint A
and quit. - Run
ghci -fprefer-byte-code -fbyte-code-and-object-code -dlint A
again and evaluatefoo
.
In 9.6, this fails STG Lint:
$ ghc --interactive -fprefer-byte-code -fbyte-code-and-object-code -dlint A
GHCi, version 9.6.2: https://www.haskell.org/ghc/ :? for help
Ok, two modules loaded.
ghci> foo
*** Stg Lint ErrMsgs: in Pre-unarise ***
<no location info>: warning:
[RHS of $fCInt :: C Int]
$fCInt1_iNi :: Int is out of scope
*** Offending Program ***
$fCInt :: C Int
[GblId[DFunId]] =
C:C! [$fEqInt $fCInt1_iNi];
...
If -dlint
is not used, then 9.6 fails with a panic in nameModule
.
In master, this fails Core Lint:
ghci> foo
*** Core Lint errors : in result of CorePrep ***
<no location info>: warning:
Out of scope: x_iO7 :: forall {t}. t
[LclId]
If -dlint
is not used, then master evaluates foo
correctly.
The error disappears with -fno-break-points
. The change in behavior between 9.6 and master happened in c59fbb0b. Looks like it improved matters but problems remain.