Skip to content

Out of scope with `-dcore-lint` and derived instances in GHCi

At revision 9e2e84e0 (current HEAD), I observe this failure:

$ ./inplace/bin/ghc-stage2 --interactive 
GHCi, version 7.7.20130902: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> newtype Age = Age Int deriving Show
Prelude> newtype Bar = Bar Age deriving Show
Prelude> Bar (Age 1))

<interactive>:4:12: parse error on input `)'
Prelude> Bar (Age 1)
Bar (Age 1)
Prelude> 
Leaving GHCi.
[jojo@kirk:3] Mo, der 02.09.2013 um 16:47 Uhr Keep Smiling :-)
~/build/haskell/ghc $ ./inplace/bin/ghc-stage2 --interactive -dcore-lint
GHCi, version 7.7.20130902: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> newtype Age = Age Int deriving Show
Prelude> newtype Bar = Bar Age deriving Show
*** Core Lint errors : in result of Desugar (after optimization) ***
<no location info>: Warning:
    In the expression: GHC.Show.showsPrec
                         @ :Interactive.Age
                         :Interactive.$fShowAge
                         (GHC.Types.I# 11)
                         (ds_dq3
                          `cast` (:Interactive.NTCo:Bar[0]
                                  :: :Interactive.Bar ~# :Interactive.Age))
    :Interactive.$fShowAge :: GHC.Show.Show :Interactive.Age
    [LclIdX[DFunId], Str=DmdType] is out of scope
*** Offending Program ***
Rec {
$cshowsPrec_apH
  :: GHC.Types.Int -> :Interactive.Bar -> GHC.Show.ShowS
[LclId, Str=DmdType]
$cshowsPrec_apH =
  \ (a_apF :: GHC.Types.Int) (ds_dq3 :: :Interactive.Bar) ->
    GHC.Show.showParen
      (GHC.Classes.>=
         @ GHC.Types.Int GHC.Classes.$fOrdInt a_apF (GHC.Types.I# 11))
      (GHC.Base..
         @ GHC.Base.String
         @ GHC.Base.String
         @ GHC.Base.String
         (GHC.Show.showString (GHC.CString.unpackCString# "Bar "#))
         (GHC.Show.showsPrec
            @ :Interactive.Age
            :Interactive.$fShowAge
            (GHC.Types.I# 11)
            (ds_dq3
             `cast` (:Interactive.NTCo:Bar[0]
                     :: :Interactive.Bar ~# :Interactive.Age))))

:Interactive.$fShowBar [InlPrag=[ALWAYS] CONLIKE]
  :: GHC.Show.Show :Interactive.Bar
[LclIdX[DFunId],
 Str=DmdType,
 Unf=DFun: \ ->
       GHC.Show.D:Show TYPE :Interactive.Bar
                       $cshowsPrec_apH
                       $cshow_apS
                       $cshowList_apU]
:Interactive.$fShowBar =
  GHC.Show.D:Show
    @ :Interactive.Bar $cshowsPrec_apH $cshow_apS $cshowList_apU

$cshowList_apU [Occ=LoopBreaker]
  :: [:Interactive.Bar] -> GHC.Show.ShowS
[LclId, Str=DmdType]
$cshowList_apU =
  GHC.Show.showList__
    @ :Interactive.Bar
    (GHC.Show.showsPrec
       @ :Interactive.Bar :Interactive.$fShowBar (GHC.Types.I# 0))

$cshow_apS [Occ=LoopBreaker] :: :Interactive.Bar -> GHC.Base.String
[LclId, Str=DmdType]
$cshow_apS =
  GHC.Show.$dmshow @ :Interactive.Bar :Interactive.$fShowBar
end Rec }

*** End of Offense ***


<no location info>: 
Compilation had errors


*** Exception: ExitFailure 1

I do not observe this in GHC.

I’ll write a test case for this.

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