Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • changelog.d/T23785
    1
    +section: compiler
    
    2
    +issues: #23785
    
    3
    +mrs: !16784
    
    4
    +synopsis:
    
    5
    +  Silence 'toIfaceIdDetails' debug messages.
    
    6
    +description:
    
    7
    +  GHC no longer emits spurious 'toIfaceIdDetails' warnings.

  • compiler/GHC/CoreToIface.hs
    ... ... @@ -447,26 +447,45 @@ toIfaceTopBndr id
    447 447
       = if isExternalName name
    
    448 448
           then IfGblTopBndr name
    
    449 449
           else IfLclTopBndr (mkIfLclName (occNameFS (getOccName id))) (toIfaceType (idType id))
    
    450
    -                        (toIfaceIdInfo (idInfo id)) (toIfaceIdDetails (idDetails id))
    
    450
    +                        (toIfaceIdInfo (idInfo id)) (toIfaceIdDetails name (idDetails id))
    
    451 451
       where
    
    452 452
         name = getName id
    
    453 453
     
    
    454
    -toIfaceIdDetails :: IdDetails -> IfaceIdDetails
    
    455
    -toIfaceIdDetails VanillaId                      = IfVanillaId
    
    456
    -toIfaceIdDetails (WorkerLikeId dmds)            = IfWorkerLikeId dmds
    
    457
    -toIfaceIdDetails (DFunId {})                    = IfDFunId
    
    458
    -toIfaceIdDetails (RecSelId { sel_naughty = n
    
    459
    -                           , sel_tycon = tc
    
    460
    -                           , sel_fieldLabel = fl }) =
    
    454
    +toIfaceIdDetails :: Name   -- ^ for trace/panic messages only
    
    455
    +                 -> IdDetails -> IfaceIdDetails
    
    456
    +toIfaceIdDetails _ VanillaId                      = IfVanillaId
    
    457
    +toIfaceIdDetails _ (WorkerLikeId dmds)            = IfWorkerLikeId dmds
    
    458
    +toIfaceIdDetails _ (DFunId {})                    = IfDFunId
    
    459
    +toIfaceIdDetails _ (RecSelId { sel_naughty = n
    
    460
    +                             , sel_tycon = tc
    
    461
    +                             , sel_fieldLabel = fl }) =
    
    461 462
       let (iface, first_con) = case tc of
    
    462 463
                     RecSelData ty_con    -> ( Left (toIfaceTyCon ty_con), dataConName $ head $ tyConDataCons ty_con)
    
    463 464
                     RecSelPatSyn pat_syn -> ( Right (patSynToIfaceDecl pat_syn), patSynName pat_syn)
    
    464 465
       in IfRecSelId iface first_con n fl
    
    465 466
     
    
    466
    -  -- The remaining cases are all "implicit Ids" which don't
    
    467
    -  -- appear in interface files at all
    
    468
    -toIfaceIdDetails other = pprTrace "toIfaceIdDetails" (ppr other)
    
    469
    -                         IfVanillaId   -- Unexpected; the other
    
    467
    +  -- NB: we deliberately handle every remaining 'IdDetails' constructor below,
    
    468
    +  --     so that anyone adding a new 'IdDetails' constructor gets an incomplete
    
    469
    +  --     pattern match warning telling them to update this code. See also #23785.
    
    470
    +
    
    471
    +toIfaceIdDetails _ (PrimOpId {})  = IfVanillaId -- Only reachable via 'pprTyThing'
    
    472
    +toIfaceIdDetails _ (ClassOpId {}) = IfVanillaId --   (e.g. GHCi :browse!)
    
    473
    +toIfaceIdDetails _ (RepPolyId {}) = IfVanillaId
    
    474
    +  -- Reachable via 'pprTyThing', but also with 'unsafeCoerce#' due to the
    
    475
    +  -- specific way it is wired-in. Otherwise we should never hit this, because
    
    476
    +  -- 'RepPolyId's are wired-in (and hence don't make it into interface files).
    
    477
    +
    
    478
    +-- Other cases should never occur (not even via 'pprTyThing').
    
    479
    +toIfaceIdDetails nm dets@(DataConWorkId {}) = not_iface_details nm dets
    
    480
    +toIfaceIdDetails nm dets@(DataConWrapId {}) = not_iface_details nm dets
    
    481
    +toIfaceIdDetails nm dets@(FCallId {})       = not_iface_details nm dets
    
    482
    +toIfaceIdDetails nm dets@(TickBoxOpId {})   = not_iface_details nm dets
    
    483
    +toIfaceIdDetails nm dets@(CoVarId {})       = not_iface_details nm dets
    
    484
    +toIfaceIdDetails nm dets@(JoinId {})        = not_iface_details nm dets
    
    485
    +
    
    486
    +not_iface_details :: HasDebugCallStack => Name -> IdDetails -> a
    
    487
    +not_iface_details nm details
    
    488
    +  = pprPanic "toIfaceIdDetails" (ppr nm <+> parens (ppr details))
    
    470 489
     
    
    471 490
     toIfaceIdInfo :: IdInfo -> IfaceIdInfo
    
    472 491
     toIfaceIdInfo id_info
    

  • compiler/GHC/Iface/Decl.hs
    ... ... @@ -68,7 +68,7 @@ idToIfaceDecl :: Id -> IfaceDecl
    68 68
     idToIfaceDecl id
    
    69 69
       = IfaceId { ifName      = getName id,
    
    70 70
                   ifType      = toIfaceType (idType id),
    
    71
    -              ifIdDetails = toIfaceIdDetails (idDetails id),
    
    71
    +              ifIdDetails = toIfaceIdDetails (getName id) (idDetails id),
    
    72 72
                   ifIdInfo    = toIfaceIdInfo (idInfo id) }
    
    73 73
     
    
    74 74
     --------------------------