Shortcut a test in exprIsOk
authorDavid Feuer <david.feuer@gmail.com>
Tue, 14 Mar 2017 20:43:37 +0000 (16:43 -0400)
committerDavid Feuer <David.Feuer@gmail.com>
Tue, 14 Mar 2017 20:43:39 +0000 (16:43 -0400)
`exprIsOk` didn't shortcut properly when checking `case` (it used
`foldl` inappropriately). Fix that.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3343

compiler/coreSyn/CoreUtils.hs

index dce7ef9..3dfb52f 100644 (file)
@@ -1130,8 +1130,8 @@ exprIsOk ok_app e
     go _ (Type {})                    = True
     go _ (Coercion {})                = True
     go n (Cast e _)                   = go n e
-    go n (Case scrut _ _ alts)        = foldl (&&) (ok scrut)
-                                        [ go n rhs | (_,_,rhs) <- alts ]
+    go n (Case scrut _ _ alts)        = ok scrut &&
+                                        and [ go n rhs | (_,_,rhs) <- alts ]
     go n (Tick t e) | tickishCounts t = False
                     | otherwise       = go n e
     go n (Lam x e)  | isRuntimeVar x  = n==0 || go (n-1) e