summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Yakimov <root@livid.pp.ru>2021-11-02 13:35:14 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-06 11:24:50 -0400
commit6f2d6a5d833810515b1e2ab11e10196ca2ba24ce (patch)
tree3e759add7e7c4b228207dd35c8574398f233ae9c
parentbe9d78625f13ec011e94ec5b68e471d13068b38f (diff)
downloadhaskell-6f2d6a5d833810515b1e2ab11e10196ca2ba24ce.tar.gz
Add regression test for #20568
GHC produced broken executables with rebindable if and -fhpc if `ifThenElse` expected non-Bool condition until GHC 9.0. This adds a simple regression test.
-rw-r--r--testsuite/tests/hpc/Makefile3
-rw-r--r--testsuite/tests/hpc/T20568.hs25
-rw-r--r--testsuite/tests/hpc/T20568.stdout1
-rw-r--r--testsuite/tests/hpc/all.T2
4 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/hpc/Makefile b/testsuite/tests/hpc/Makefile
index fdbbda14e0..6dd6d8f8b8 100644
--- a/testsuite/tests/hpc/Makefile
+++ b/testsuite/tests/hpc/Makefile
@@ -15,3 +15,6 @@ T17073:
"$(HPC)" version
LANG=ASCII "$(HPC)" markup T17073
+T20568:
+ "$(TEST_HC)" $(TEST_HC_ARGS) T20568.hs -fhpc -v0
+ ./T20568
diff --git a/testsuite/tests/hpc/T20568.hs b/testsuite/tests/hpc/T20568.hs
new file mode 100644
index 0000000000..929f3eeb1c
--- /dev/null
+++ b/testsuite/tests/hpc/T20568.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE RebindableSyntax #-}
+
+-- | Test for #20586 regression: rebindable if shouldn't crash
+module Main where
+
+import Prelude
+
+main :: IO ()
+main = print $ program
+ where
+ program :: AST
+ program =
+ if AstBool True
+ then AstInt 1
+ else AstInt 2
+
+data AST =
+ AstGT AST AST
+ | AstInt Integer
+ | AstBool Bool
+ | IfThenElse AST AST AST
+ deriving Show
+
+ifThenElse :: AST -> AST -> AST -> AST
+ifThenElse = IfThenElse
diff --git a/testsuite/tests/hpc/T20568.stdout b/testsuite/tests/hpc/T20568.stdout
new file mode 100644
index 0000000000..0ea786fafe
--- /dev/null
+++ b/testsuite/tests/hpc/T20568.stdout
@@ -0,0 +1 @@
+IfThenElse (AstBool True) (AstInt 1) (AstInt 2)
diff --git a/testsuite/tests/hpc/all.T b/testsuite/tests/hpc/all.T
index 74e0e3e2e4..6744daa92f 100644
--- a/testsuite/tests/hpc/all.T
+++ b/testsuite/tests/hpc/all.T
@@ -24,3 +24,5 @@ test('T2991', [cmd_wrapper(T2991), extra_clean(['T2991LiterateModule.hi',
test('T17073', when(opsys('mingw32'), expect_broken(17607)),
makefile_test, ['T17073 HPC={hpc}'])
+
+test('T20568', normal, makefile_test, [])