Skip to content

Commit

Permalink
Don't barf on 'HsSpliceTy' (haskell#745)
Browse files Browse the repository at this point in the history
This handles 'HsSpliceTy's by replacing them with what they expand to.
IIUC everything that is happening, 'renameHsSpliceTy' should not be
able to fail for the inputs we feed it from GHC.

This fixes haskell#574.

(cherry picked from commit 1446450)
  • Loading branch information
harpocrates authored and sjakobi committed Jun 10, 2018
1 parent 5c99281 commit af7a441
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion haddock-api/src/Haddock/Interface/Rename.hs
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,21 @@ renameType t = case t of
(XHsType (NHsCoreTy a)) -> pure (XHsType (NHsCoreTy a))
HsExplicitListTy x i b -> HsExplicitListTy x i <$> mapM renameLType b
HsExplicitTupleTy x b -> HsExplicitTupleTy x <$> mapM renameLType b
HsSpliceTy _ _ -> error "renameType: HsSpliceTy"
HsSpliceTy _ s -> renameHsSpliceTy s
HsWildCardTy a -> HsWildCardTy <$> renameWildCardInfo a
HsAppsTy _ _ -> error "renameType: HsAppsTy"

-- | Rename splices, but _only_ those that turn out to be for types.
-- I think this is actually safe for our possible inputs:
--
-- * the input is from after GHC's renamer, so should have an 'HsSpliced'
-- * the input is typechecked, and only 'HsSplicedTy' should get through that
--
renameHsSpliceTy :: HsSplice GhcRn -> RnM (HsType DocNameI)
renameHsSpliceTy (HsSpliced _ _ (HsSplicedTy t)) = renameType t
renameHsSpliceTy (HsSpliced _ _ _) = error "renameHsSpliceTy: not an HsSplicedTy"
renameHsSpliceTy _ = error "renameHsSpliceTy: not an HsSpliced"

renameLHsQTyVars :: LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars (HsQTvs { hsq_explicit = tvs })
= do { tvs' <- mapM renameLTyVarBndr tvs
Expand Down

0 comments on commit af7a441

Please sign in to comment.