Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Don't barf on 'HsSpliceTy' #745

Merged
merged 1 commit into from
Feb 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -264,10 +264,21 @@ renameType t = case t of
HsCoreTy a -> pure (HsCoreTy a)
HsExplicitListTy i a b -> HsExplicitListTy i a <$> mapM renameLType b
HsExplicitTupleTy a b -> HsExplicitTupleTy a <$> 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 Name -> RnM (HsType DocName)
renameHsSpliceTy (HsSpliced _ (HsSplicedTy t)) = renameType t
renameHsSpliceTy (HsSpliced _ _) = error "renameHsSpliceTy: not an HsSplicedTy"
renameHsSpliceTy _ = error "renameHsSpliceTy: not an HsSpliced"

renameLHsQTyVars :: LHsQTyVars Name -> RnM (LHsQTyVars DocName)
renameLHsQTyVars (HsQTvs { hsq_implicit = _, hsq_explicit = tvs })
= do { tvs' <- mapM renameLTyVarBndr tvs
Expand Down