Commit 55b27a32 authored by David Feuer's avatar David Feuer Committed by Ben Gamari

Deal with unbreakable blocks in Applicative Do

The renamer wasn't able to deal with more than a couple strict
patterns in a row with `ApplicativeDo` when using the heuristic
splitter. Update it to work with them properly.

Reviewers: simonmar, austin, bgamari, hvr

Reviewed By: simonmar

Subscribers: RyanGlScott, lippling, rwbarton, thomie

GHC Trac Issues: #14163

Differential Revision:

(cherry picked from commit 011e15aa)
parent 14195b09
......@@ -1797,9 +1797,12 @@ slurpIndependentStmts
slurpIndependentStmts stmts = go [] [] emptyNameSet stmts
-- If we encounter a BindStmt that doesn't depend on a previous BindStmt
-- in this group, then add it to the group.
-- in this group, then add it to the group. We have to be careful about
-- strict patterns though; splitSegments expects that if we return Just
-- then we have actually done some splitting. Otherwise it will go into
-- an infinite loop (#14163).
go lets indep bndrs ((L loc (BindStmt pat body bind_op fail_op ty), fvs) : rest)
| isEmptyNameSet (bndrs `intersectNameSet` fvs)
| isEmptyNameSet (bndrs `intersectNameSet` fvs) && not (isStrictPattern pat)
= go lets ((L loc (BindStmt pat body bind_op fail_op ty), fvs) : indep)
bndrs' rest
where bndrs' = bndrs `unionNameSet` mkNameSet (collectPatBinders pat)
{-# language ApplicativeDo #-}
import GHC.Exts
readIt :: IO (Int, Int)
readIt = readLn
main :: IO ()
main = do
(_, _) <- readIt
(_, _) <- readIt
(_, _) <- readIt
print "Done"
......@@ -10,3 +10,4 @@ test('ado-optimal', normal, compile_and_run, [''])
test('T12490', normal, compile, [''])
test('T13242', normal, compile, [''])
test('T13875', normal, compile_and_run, [''])
test('T14163', normal, compile_and_run, [''])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment