diff options
Diffstat (limited to 'compiler/GHC/IfaceToCore.hs')
-rw-r--r-- | compiler/GHC/IfaceToCore.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/GHC/IfaceToCore.hs b/compiler/GHC/IfaceToCore.hs index 66a143b0b4..bf40b2947c 100644 --- a/compiler/GHC/IfaceToCore.hs +++ b/compiler/GHC/IfaceToCore.hs @@ -1291,13 +1291,24 @@ tcIfaceCompleteMatches :: [IfaceCompleteMatch] -> IfL [CompleteMatch] tcIfaceCompleteMatches = mapM tcIfaceCompleteMatch tcIfaceCompleteMatch :: IfaceCompleteMatch -> IfL CompleteMatch -tcIfaceCompleteMatch (IfaceCompleteMatch ms mtc) = do - conlikes <- mkUniqDSet <$> mapM (forkM doc . tcIfaceConLike) ms +tcIfaceCompleteMatch (IfaceCompleteMatch ms mtc) = forkM doc $ do -- See Note [Positioning of forkM] + conlikes <- mkUniqDSet <$> mapM tcIfaceConLike ms mtc' <- traverse tcIfaceTyCon mtc return (CompleteMatch conlikes mtc') where doc = text "COMPLETE sig" <+> ppr ms +{- Note [Positioning of forkM] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We need to be lazy when type checking the interface, since these functions are +called when the interface itself is being loaded, which means it is not in the +PIT yet. If we are not lazy enough, in certain cases we might recursively try to +load the same interface in an infinite loop. + +For this reason, the forkM should be around as much of the computation as +possible. +-} + {- ************************************************************************ * * |