@@ -19,7 +19,7 @@ import Language.PureScript.Errors (MultipleErrors, SimpleErrorMessage(..), addHi
1919import Language.PureScript.Linter.Exhaustive as L
2020import Language.PureScript.Linter.Imports as L
2121import Language.PureScript.Names (Ident (.. ), Qualified (.. ), QualifiedBy (.. ), getIdentName , runIdent )
22- import Language.PureScript.Types (Constraint (.. ), SourceType , Type (.. ), everythingWithContextOnTypes )
22+ import Language.PureScript.Types (Constraint (.. ), SourceType , Type (.. ), everythingOnTypes , everythingWithContextOnTypes )
2323import Language.PureScript.Constants.Libs qualified as C
2424
2525-- | Lint the PureScript AST.
@@ -222,7 +222,7 @@ lintUnused (Module modSS _ mn modDecls exports) =
222222 in
223223 mconcat $ map go vs ++ map f alts
224224
225- go (TypedValue _ v1 _ ) = go v1
225+ go (TypedValue _ v1 ty ) = go v1 <> goType ty
226226 go (Do _ es) = doElts es Nothing
227227 go (Ado _ es v1) = doElts es (Just v1)
228228
@@ -240,6 +240,10 @@ lintUnused (Module modSS _ mn modDecls exports) =
240240 go AnonymousArgument = mempty
241241 go (Hole _) = mempty
242242
243+ goType :: SourceType -> (S. Set Name , MultipleErrors )
244+ goType = everythingOnTypes (<>) $ \ case
245+ TypeConstructor _ (Qualified (BySourcePos _) t) -> (S. singleton $ TyName t, mempty )
246+ _ -> mempty
243247
244248 doElts :: [DoNotationElement ] -> Maybe Expr -> (S. Set Name , MultipleErrors )
245249 doElts (DoNotationValue e : rest) v = go e <> doElts rest v
@@ -257,6 +261,7 @@ lintUnused (Module modSS _ mn modDecls exports) =
257261 declNames :: Declaration -> (S. Set (SourceSpan , Name ), S. Set (SourceSpan , Name ))
258262 declNames (ValueDecl (ss,_) ident _ _ _) = (S. empty, S. singleton (ss, IdentName ident))
259263 declNames (BoundValueDeclaration _ binders _) = (S. fromList $ binderNamesWithSpans' binders, S. empty)
264+ declNames (TypeSynonymDeclaration (ss,_) ty _ _) = (S. singleton (ss, TyName ty), S. empty)
260265 declNames _ = (S. empty, S. empty)
261266
262267 onDecls :: [ Declaration ] -> (S. Set Name , MultipleErrors ) -> (S. Set Name , MultipleErrors )
@@ -280,6 +285,8 @@ lintUnused (Module modSS _ mn modDecls exports) =
280285 removeAndWarn bindNewNames $ foldr1 (<>) $ map go allExprs
281286 -- let {x} = e -- no binding to check inside e
282287 underDecl (BoundValueDeclaration _ _ expr) = go expr
288+ -- let f :: t -- check t
289+ underDecl (TypeDeclaration TypeDeclarationData {.. }) = goType tydeclType
283290 underDecl _ = (mempty , mempty )
284291
285292 unguard (GuardedExpr guards expr) = map unguard' guards ++ [expr]
0 commit comments