diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-02-05 22:59:09 -0800 |
---|---|---|
committer | alexbiehl <alex.biehl@gmail.com> | 2018-02-06 08:24:47 +0100 |
commit | 1446450a2e9b4bacf32931ee58199bfc3c6ff3ac (patch) | |
tree | ea89971f29fa4457f37d9ec71d72ce24e6bf7d0f /haddock-api/src/Haddock/Interface | |
parent | 8bf36bde2892ec0ce21a85fea403a5807f9cdd80 (diff) |
Don't barf on 'HsSpliceTy' (#745)
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 #574.
Diffstat (limited to 'haddock-api/src/Haddock/Interface')
-rw-r--r-- | haddock-api/src/Haddock/Interface/Rename.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Interface/Rename.hs b/haddock-api/src/Haddock/Interface/Rename.hs index 2d3a28cc..78ab5a08 100644 --- a/haddock-api/src/Haddock/Interface/Rename.hs +++ b/haddock-api/src/Haddock/Interface/Rename.hs @@ -273,10 +273,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 GhcRn -> RnM (LHsQTyVars DocNameI) renameLHsQTyVars (HsQTvs { hsq_implicit = _, hsq_explicit = tvs }) = do { tvs' <- mapM renameLTyVarBndr tvs |