[commit: ghc] master: Fix a bug in -foptimal-applicative-do (7e0ef11)
git at git.haskell.org
git at git.haskell.org
Tue Jun 13 00:22:54 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/7e0ef11324712b4ff3ac8f39259e5ecbd63c2356/ghc
>---------------------------------------------------------------
commit 7e0ef11324712b4ff3ac8f39259e5ecbd63c2356
Author: Simon Marlow <marlowsd at gmail.com>
Date: Mon Jun 12 17:00:39 2017 -0400
Fix a bug in -foptimal-applicative-do
Test Plan: validate
Reviewers: bgamari, niteria, austin, erikd
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3640
>---------------------------------------------------------------
7e0ef11324712b4ff3ac8f39259e5ecbd63c2356
compiler/rename/RnExpr.hs | 2 +-
testsuite/tests/ado/ado-optimal.hs | 11 +++++++++++
testsuite/tests/ado/ado-optimal.stdout | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index e1a314f..2c779d2 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -1605,7 +1605,7 @@ mkStmtTreeOptimal stmts =
(StmtTreeOne (stmt_arr ! hi), 1))
| left_cost < right_cost
= ((left,left_cost), (StmtTreeOne (stmt_arr ! hi), 1))
- | otherwise -- left_cost > right_cost
+ | left_cost > right_cost
= ((StmtTreeOne (stmt_arr ! lo), 1), (right,right_cost))
| otherwise = minimumBy (comparing cost) alternatives
where
diff --git a/testsuite/tests/ado/ado-optimal.hs b/testsuite/tests/ado/ado-optimal.hs
index aab8d53..d67aa4f 100644
--- a/testsuite/tests/ado/ado-optimal.hs
+++ b/testsuite/tests/ado/ado-optimal.hs
@@ -18,8 +18,19 @@ test1 = do
x5 <- const e (x1,x4)
return (const () x5)
+-- (a | c); (b | d); e
+test2 :: M ()
+test2 = do
+ x1 <- a
+ x3 <- c
+ x2 <- const b x1
+ x4 <- const d x3
+ x5 <- const e (x1,x4)
+ return (const () x5)
+
main = mapM_ run
[ test1
+ , test2
]
-- Testing code, prints out the structure of a monad/applicative expression
diff --git a/testsuite/tests/ado/ado-optimal.stdout b/testsuite/tests/ado/ado-optimal.stdout
index 29f9856..1df5e57 100644
--- a/testsuite/tests/ado/ado-optimal.stdout
+++ b/testsuite/tests/ado/ado-optimal.stdout
@@ -1 +1,2 @@
((a; b) | (c; d)); e
+(a | c); ((b | d); e)
More information about the ghc-commits
mailing list