git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Restrict the number of binders when checking exhaustivity, fix #1469, fix #1288.
commit268acb561c7c422d02bfd2fe8ef39436935966dd authorPhil Freeman <paf31@cantab.net> dateMon 14 Sep 2015, 10:46 (11 years ago) parente2385f4
1 file changed+6−3
src/Language/PureScript/Linter/Exhaustive.hs+6−3
src/Language/PureScript/Linter/Exhaustive.hs+6−3
@@ -223,6 +223,8 @@ missingAlternative env mn ca uncovered
223223 where
224224 mcases = missingCases env mn uncovered ca
225225
226+
227+
226228-- |
227229-- Main exhaustivity checking function
228230-- Starting with the set `uncovered = { _ }` (nothing covered, one `_` for each function argument),
@@ -235,9 +237,10 @@ checkExhaustive env mn numArgs cas = makeResult . first nub $ foldl' step ([init
235237 step :: ([[Binder]], (Maybe Bool, [[Binder]])) -> CaseAlternative -> ([[Binder]], (Maybe Bool, [[Binder]]))
236238 step (uncovered, (nec, redundant)) ca =
237239 let (missed, pr) = unzip (map (missingAlternative env mn ca) uncovered)
238− cond = or <$> sequenceA pr
239− in (concat missed, (liftA2 (&&) cond nec,
240− if fromMaybe True cond then redundant else caseAlternativeBinders ca : redundant))
240+ (missed', approx) = splitAt 10000 (concat missed)
241+ cond = liftA2 (&&) (or <$> sequenceA pr) nec
242+ in (missed', (if null approx then cond else Nothing,
243+ if fromMaybe True cond then redundant else caseAlternativeBinders ca : redundant))
241244#if __GLASGOW_HASKELL__ < 710
242245 where
243246 sequenceA = foldr (liftA2 (:)) (pure [])