summaryrefslogtreecommitdiff
path: root/testsuite/tests/safeHaskell
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2021-01-20 20:33:30 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-13 21:28:49 -0500
commitf1362008daabb518b6fcd8079fb89683fb642597 (patch)
tree171d08636f12373e4a721ed2449f0fe4c60f3d0f /testsuite/tests/safeHaskell
parent448fd22d84a6d8100448861633f7918584bf97e8 (diff)
downloadhaskell-f1362008daabb518b6fcd8079fb89683fb642597.tar.gz
Always set `safeInferred`, not only when it turns `False`
previously, `safeFlagCheck` would be happy to switch the `safeFlag` to `False`, but not the other way around. This meant that after :set -XGeneralizedNewtypeDeriving :set -XNoGeneralizedNewtypeDeriving in GHCi all loaded files would be still be infered as unsafe. This fixes #19243. This is a corner case, but somewhat relevant once ghci by default starts with `GeneralizedNewtypeDeriving` on (due to GHC2021).
Diffstat (limited to 'testsuite/tests/safeHaskell')
-rw-r--r--testsuite/tests/safeHaskell/ghci/T19243.hs4
-rw-r--r--testsuite/tests/safeHaskell/ghci/T19243.script5
-rw-r--r--testsuite/tests/safeHaskell/ghci/T19243.stdout4
-rw-r--r--testsuite/tests/safeHaskell/ghci/all.T1
4 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/safeHaskell/ghci/T19243.hs b/testsuite/tests/safeHaskell/ghci/T19243.hs
new file mode 100644
index 0000000000..b32102030e
--- /dev/null
+++ b/testsuite/tests/safeHaskell/ghci/T19243.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE Haskell2010 #-}
+module T19234 where
+class A a
+instance A Int
diff --git a/testsuite/tests/safeHaskell/ghci/T19243.script b/testsuite/tests/safeHaskell/ghci/T19243.script
new file mode 100644
index 0000000000..ad2fc64777
--- /dev/null
+++ b/testsuite/tests/safeHaskell/ghci/T19243.script
@@ -0,0 +1,5 @@
+:set -XGeneralizedNewtypeDeriving
+:set -XNoGeneralizedNewtypeDeriving
+:load T19243
+-- The following should report safe
+:info A
diff --git a/testsuite/tests/safeHaskell/ghci/T19243.stdout b/testsuite/tests/safeHaskell/ghci/T19243.stdout
new file mode 100644
index 0000000000..93828deb9b
--- /dev/null
+++ b/testsuite/tests/safeHaskell/ghci/T19243.stdout
@@ -0,0 +1,4 @@
+type A :: * -> Constraint
+class A a
+ -- Defined at T19243.hs:3:1
+instance [safe] A Int -- Defined at T19243.hs:4:10
diff --git a/testsuite/tests/safeHaskell/ghci/all.T b/testsuite/tests/safeHaskell/ghci/all.T
index 040cc288f9..26f72d20b8 100644
--- a/testsuite/tests/safeHaskell/ghci/all.T
+++ b/testsuite/tests/safeHaskell/ghci/all.T
@@ -19,4 +19,5 @@ test('p17', normalise_version("bytestring"), ghci_script, ['p17.script'])
# 7172
test('p18', normalise_version("bytestring"), ghci_script, ['p18.script'])
test('T12509', [extra_hc_opts('-XSafe')], ghci_script, ['T12509.script'])
+test('T19243', normal, ghci_script, ['T19243.script'])