Opened 2 years ago

Closed 2 years ago

#13481 closed bug (fixed)

T12622 fails in ghci way

Reported by: bgamari Owned by: bgamari
Priority: high Milestone: 8.2.2
Component: Compiler Version: 8.1
Keywords: StaticPointers Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case: T12622
Blocked By: Blocking:
Related Tickets: #12622, #12356 Differential Rev(s): Phab:D3920
Wiki Page:

Description

T12622, which is intended to test StaticPointers, fails in the GHCi way with a core lint warning,

*** Core Lint errors : in result of Float out(FOS {Lam = Just 0,                                                                                              
                                                   Consts = True,                                                                                        
                                                   OverSatApps = False}) ***                                                                                 
<no location info>: warning:                                                                                                                               
    In the expression: >>=                                                                                                                               
                         @ IO                                                                                                                                
                         $fMonadIO                                                                                                                              
                         @ (Bool -> Bool)                                                                                                                           
                         @ ()                                                                                                                                   
                         (break<10>(s_a1DF) lvl_s3bD)                                                                                                               
                         lvl_s3bE                                                                                             
    s_a1DF :: StaticPtr (Bool -> Bool)                                                                                            
    [LclId,                                                                                                                   
     Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
             WorkFree=False, Expandable=False,
             Guidance=IF_ARGS [] 70 0}] is out of scope
*** Offending Program ***
g :: Bool
[LclIdX]
g = break<15>() True

$trModule_s3b7 :: Addr#
[LclId]
$trModule_s3b7 = "main"#

$trModule_s3b6 :: TrName
[LclId]
$trModule_s3b6 = TrNameS $trModule_s3b7

$trModule_s3b9 :: Addr#
[LclId]
$trModule_s3b9 = "Main"#

$trModule_s3b8 :: TrName
[LclId]
$trModule_s3b8 = TrNameS $trModule_s3b9

$trModule :: Module
[LclIdX]
$trModule = Module $trModule_s3b6 $trModule_s3b8

lvl_s3bj :: Addr#
[LclId]
lvl_s3bj = "error"#

lvl_s3bk :: [Char]
[LclId]
lvl_s3bk = unpackCString# lvl_s3bj

lvl_s3bl :: Addr#
[LclId]
lvl_s3bl = "main"#

lvl_s3bm :: [Char]
[LclId]
lvl_s3bm = unpackCString# lvl_s3bl

lvl_s3bn :: Addr#
[LclId]
lvl_s3bn = "Main"#

lvl_s3bo :: [Char]
[LclId]
lvl_s3bo = unpackCString# lvl_s3bn
lvl_s3bp :: Addr#
[LclId]
lvl_s3bp = "T12622.hs"#

lvl_s3bq :: [Char]
[LclId]
lvl_s3bq = unpackCString# lvl_s3bp

lvl_s3br :: Int
[LclId]
lvl_s3br = I# 21#

lvl_s3bs :: Int
[LclId]
lvl_s3bs = I# 14#

lvl_s3bt :: Int
[LclId]
lvl_s3bt = I# 21#

lvl_s3bu :: Int
[LclId]
lvl_s3bu = I# 64#

lvl_s3bv :: SrcLoc
[LclId]
lvl_s3bv
  = SrcLoc
      lvl_s3bm lvl_s3bo lvl_s3bq lvl_s3br lvl_s3bs lvl_s3bt lvl_s3bu

lvl_s3bw :: ([Char], SrcLoc)
[LclId]
lvl_s3bw = (lvl_s3bk, lvl_s3bv)

$dIP_s3bc :: CallStack
[LclId]
$dIP_s3bc = pushCallStack lvl_s3bw emptyCallStack

lvl_s3bx :: Addr#
[LclId]
lvl_s3bx = "couldn't find "#

lvl_s3by :: [Char]
[LclId]
lvl_s3by = unpackCString# lvl_s3bx

lookupKey :: forall a. StaticPtr a -> IO a
[LclIdX, Arity=1]
lookupKey
  = \ (@ a_a23X) (p_X1DX :: StaticPtr a_a23X) ->                              
      break<8>(p_X1DX)                              
      >>=                                                                     
        @ IO          
        $fMonadIO
        @ (Maybe (StaticPtr a_a23X))
        @ a_a23X             
        (break<1>(p_X1DX)           
         unsafeLookupStaticPtr              
           @ a_a23X (break<0>(p_X1DX) staticKey @ a_a23X p_X1DX))
        (\ (ds_d3as :: Maybe (StaticPtr a_a23X)) ->
           case ds_d3as of {                                     
             Nothing ->                            
               break<7>(p_X1DX)  
               error   
                 @ 'LiftedRep                                
                 @ (IO a_a23X)
                 ($dIP_s3bc                                  
                  `cast` (Sym (N:IP[0] <"callStack">_N <CallStack>_N)
                          :: (CallStack :: *) ~R# ((?callStack::CallStack) :: Constraint)))
                 (break<6>(p_X1DX)                                   
                  ++                                                                       
                    @ Char        
                    lvl_s3by
                    (break<5>(p_X1DX)
                     show   
                       @ StaticPtrInfo
                       $fShowStaticPtrInfo
                       (break<4>(p_X1DX) staticPtrInfo @ a_a23X p_X1DX)));
             Just p_a1DI ->               
               break<3>(p_a1DI)                                           
               return      
                 @ IO          
                 $fMonadIO
                 @ a_a23X 
                 (break<2>(p_a1DI) deRefStaticPtr @ a_a23X p_a1DI)
           })            
                                                                  
$dTypeable_s3bA :: TypeRep Bool
[LclId]                   
$dTypeable_s3bA = mkTrCon @ * @ Bool $tcBool ([] @ SomeTypeRep)
                            
s_s3bC :: StaticPtr (Bool -> Bool)                             
[LclId]                         
s_s3bC                            
  = case break<9>()             
         sg                  
           @ Bool                      
           ($dTypeable_s3bA                                      
            `cast` (Sym N:Typeable[0] <*>_N <Bool>_N
                    :: (TypeRep Bool :: *) ~R# (Typeable Bool :: Constraint)))
    of
    { T s_a38b ->
    s_a38b
    }

lvl_s3bD :: IO (Bool -> Bool)
[LclId]
lvl_s3bD = lookupKey @ (Bool -> Bool) s_s3bC

lvl_s3bE :: (Bool -> Bool) -> IO ()
[LclId]
lvl_s3bE
  = \ (f_a1DG :: Bool -> Bool) ->
      break<12>(f_a1DG)
      print @ Bool $fShowBool (break<11>(f_a1DG) f_a1DG True)

main :: IO ()
[LclIdX]
main
  = break<14>()
    break<13>(s_s3bC)
    >>=
      @ IO
      $fMonadIO
      @ (Bool -> Bool)
      @ ()
      (break<10>(s_a1DF) lvl_s3bD)
      lvl_s3bE

main :: IO ()
[LclIdX]
main = runMainIO @ () main

*** End of Offense ***


<no location info>: error:
Compilation had errors


*** Exception: ExitFailure 1
===== program output begins here
===== program output begins here

T12622:6:30: error:
    Not in scope: ‘Main.main’
    No module named ‘Main’ is imported.

Change History (12)

comment:1 Changed 2 years ago by Ben Gamari <ben@…>

In 140a2d1c/ghc:

testsuite: Mark T12622 as broken in ghci way

See #13481.

comment:2 Changed 2 years ago by bgamari

comment:3 Changed 2 years ago by simonpj

Keywords: StaticPointers added
Owner: set to facundo.dominguez

Facundo, any ideas?

comment:4 Changed 2 years ago by bgamari

Owner: changed from facundo.dominguez to bgamari

comment:5 Changed 2 years ago by bgamari

Milestone: 8.2.18.2.2
Priority: normalhigh

I'm afraid this will need to wait for 8.2.2. Bumping priority to ensure I get to it.

comment:6 Changed 2 years ago by bgamari

I'll try to have a look at this on the plane to ICFP.

comment:7 Changed 2 years ago by bgamari

Test Case: T12622

comment:8 Changed 2 years ago by bgamari

It looks like the cause here is that we started out with,

main :: IO ()
[LclIdX]
main
  = break<14>()
    let {
      s_a2kk :: StaticPtr (Bool -> Bool)
      [LclId]
      s_a2kk = ...
    } in
    break<13>(s_a2kk) 
    >>=
      @ IO
      GHC.Base.$fMonadIO
      @ (Bool -> Bool)
      @ ()
      (break<10>(s_a2kk) lookupKey @ (Bool -> Bool) s_a2kk)
      (...)

But then FloatOut floats s_a2kk out of the let giving it a new name (s_s3Sy) in the process. Somehow main then gets partially rewritten to,

main :: IO ()
[LclIdX]
main
  = break<14>()
    break<13>(s_s3Sy)
    >>=
      @ IO
      $fMonadIO
      @ (Bool -> Bool)
      @ ()
      (break<10>(s_a2kk) lvl_s3Sz)
      lvl_s3SA

Note the mention of s_a2kk remaining in break<10>, despite the fact that the reference in break<13> was correctly renamed.

comment:9 Changed 2 years ago by bgamari

Differential Rev(s): Phab:D3920
Status: newpatch

comment:10 Changed 2 years ago by Ben Gamari <ben@…>

In cd857dd4/ghc:

SetLevels: Substitute in ticks in lvlMFE

Previously SetLevels.lvlMFE would fail to substitute in ticks, unlike
lvlExpr.  This lead to #13481. Fix this.

Test Plan: `make test TEST=T12622 WAY=ghci`

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13481

Differential Revision: https://phabricator.haskell.org/D3920

comment:11 Changed 2 years ago by bgamari

Status: patchmerge

comment:12 Changed 2 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.