summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorAaron Allen <aaron@flipstone.com>2021-05-04 21:35:11 -0500
committerBen Gamari <ben@smart-cactus.org>2021-05-13 10:05:30 -0400
commitf1a6f7267d0b9f181fb3b9b1b0cbfa2d07d39fb9 (patch)
tree79fd1316c99d06efcdae404ce9ed52aefbda15c3 /testsuite
parent032f18156aef13269c81047cdf409c1238d5967f (diff)
downloadhaskell-f1a6f7267d0b9f181fb3b9b1b0cbfa2d07d39fb9.tar.gz
Disallow -XDerivingVia when -XSafe is on (#19786)
Since `GeneralizedNewtypeDeriving` is considered unsafe, `DerivingVia` should be as well. (cherry picked from commit 0281dae8b3fe3384939c415ae72ca2440b3cafb3)
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang19.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang19.stderr3
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/all.T1
3 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang19.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang19.hs
new file mode 100644
index 0000000000..915876a838
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang19.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE Safe, DerivingVia #-}
+
+-- | Tests that Safe disables DerivingVia (#19786)
+module SafeLang19 where
+
+f :: Int
+f = 1
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang19.stderr b/testsuite/tests/safeHaskell/safeLanguage/SafeLang19.stderr
new file mode 100644
index 0000000000..1dbe65d156
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang19.stderr
@@ -0,0 +1,3 @@
+
+SafeLang19.hs:2:20: warning:
+ -XDerivingVia is not allowed in Safe Haskell; ignoring -XDerivingVia
diff --git a/testsuite/tests/safeHaskell/safeLanguage/all.T b/testsuite/tests/safeHaskell/safeLanguage/all.T
index de4a9b6908..ac15d88a21 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/all.T
+++ b/testsuite/tests/safeHaskell/safeLanguage/all.T
@@ -32,6 +32,7 @@ test('SafeLang16', normal, compile, [''])
test('SafeLang17', [], multimod_compile_fail, ['SafeLang17', ''])
test('SafeLang18', normal, compile, [''])
+test('SafeLang19', normal, compile, [''])
# Test building a package, that trust values are set correctly
# and can be changed correctly