Skip to content

Commit f73a5ff

Browse files
committed
Print five exhaustivity checking warnings for each definition instead the whole set.
1 parent 08ab297 commit f73a5ff

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Language/PureScript/Errors.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ data SimpleErrorMessage
120120
| TransitiveExportError DeclarationRef [DeclarationRef]
121121
| ShadowedName Ident
122122
| WildcardInferredType Type
123-
| NotExhaustivePattern [[Binder]]
123+
| NotExhaustivePattern [[Binder]] Bool
124124
| ClassOperator ProperName Ident
125125
deriving (Show)
126126

@@ -230,7 +230,7 @@ errorCode em = case unwrapErrorMessage em of
230230
(TransitiveExportError _ _) -> "TransitiveExportError"
231231
(ShadowedName _) -> "ShadowedName"
232232
(WildcardInferredType _) -> "WildcardInferredType"
233-
(NotExhaustivePattern _) -> "NotExhaustivePattern"
233+
(NotExhaustivePattern _ _) -> "NotExhaustivePattern"
234234
(ClassOperator _ _) -> "ClassOperator"
235235

236236
-- |
@@ -561,11 +561,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
561561
]
562562
goSimple (WildcardInferredType ty) =
563563
line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
564-
goSimple (NotExhaustivePattern bs) =
565-
paras $ [ line "Pattern could not be determined to cover all cases."
564+
goSimple (NotExhaustivePattern bs b) =
565+
indent $ paras $ [ line "Pattern could not be determined to cover all cases."
566566
, line $ "The definition has the following uncovered cases:\n"
567-
, indent $ Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
568-
]
567+
, Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
568+
] ++ if not b then [line "..."] else []
569569
go (NotYetDefined names err) =
570570
paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
571571
, indent $ go err

src/Language/PureScript/Linter/Exhaustive.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Data.Function (on)
3131

3232
import Control.Monad (unless)
3333
import Control.Applicative
34+
import Control.Arrow (second)
3435
import Control.Monad.Writer.Class
3536

3637
import Language.PureScript.AST.Binders
@@ -241,7 +242,7 @@ checkExhaustive env mn cas = makeResult . nub $ foldl' step [initial] cas
241242
makeResult :: [[Binder]] -> m ()
242243
makeResult bss = unless (null bss) tellWarning
243244
where
244-
tellWarning = tell . errorMessage $ NotExhaustivePattern bss
245+
tellWarning = tell . errorMessage . uncurry NotExhaustivePattern . second null . splitAt 5 $ bss
245246

246247
-- |
247248
-- Exhaustivity checking over a list of declarations

0 commit comments

Comments
 (0)