Skip to content

Commit

Permalink
Justify the use of unsafePerformIO in a comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
facundominguez authored Oct 24, 2024
1 parent 1e3b291 commit 05b819a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,12 @@ ofBRType env name f l = go []
lc' = F.atLoc lc <$> matchTyCon env lc
lc = btc_tc tc

-- | Get the TyCon from an LHName.
--
-- This function uses 'unsafePerformIO' to lookup the 'Ghc.TyThing' of a 'Ghc.Name'.
-- This should be benign because the result doesn't depend of when exactly this is
-- called. Since this code is intended to be used inside a GHC plugin, there is no
-- danger that GHC is finalized before the result is evaluated.
matchTyCon :: Env -> Located LHName -> Lookup Ghc.TyCon
matchTyCon env lc@(Loc _ _ c0) = unsafePerformIO $ do
case c0 of
Expand Down

0 comments on commit 05b819a

Please sign in to comment.