summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhaimin Ahsan <leroux@fezrev.com>2014-11-21 11:31:44 -0600
committerAustin Seipp <austin@well-typed.com>2014-11-21 11:31:45 -0600
commit3e4f49b04e6e97256b4d34221e209e1051bf06ae (patch)
tree1db1538ea4a5b6c3df77c55c035fd65db4b0c228
parent803fc5db31f084b73713342cdceaed5a9c664267 (diff)
downloadhaskell-3e4f49b04e6e97256b4d34221e209e1051bf06ae.tar.gz
Fixes ghci :unset -X<ext> so that it doesn't fail to reverse option. (fixes trac #9293)
Summary: ghci unset could not reverse language extensions. Reviewers: hvr, thomie, austin Reviewed By: hvr, thomie, austin Subscribers: goldfire, hvr, thomie, carter Differential Revision: https://phabricator.haskell.org/D516 GHC Trac Issues: #9293
-rw-r--r--ghc/InteractiveUI.hs1
-rw-r--r--testsuite/tests/ghci/scripts/T9293.hs3
-rw-r--r--testsuite/tests/ghci/scripts/T9293.script27
-rw-r--r--testsuite/tests/ghci/scripts/T9293.stderr19
-rw-r--r--testsuite/tests/ghci/scripts/T9293.stdout54
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
-rw-r--r--testsuite/tests/safeHaskell/ghci/p12.stderr4
-rw-r--r--testsuite/tests/safeHaskell/ghci/p5.stderr6
8 files changed, 110 insertions, 5 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index f5a1bbe938..7fdda0b0fd 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -2182,6 +2182,7 @@ unsetOptions str
]
no_flag ('-':'f':rest) = return ("-fno-" ++ rest)
+ no_flag ('-':'X':rest) = return ("-XNo" ++ rest)
no_flag f = throwGhcException (ProgramError ("don't know how to reverse " ++ f))
in if (not (null rest3))
diff --git a/testsuite/tests/ghci/scripts/T9293.hs b/testsuite/tests/ghci/scripts/T9293.hs
new file mode 100644
index 0000000000..f7329c97e5
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9293.hs
@@ -0,0 +1,3 @@
+module Test where
+data T a where
+ C :: T Int
diff --git a/testsuite/tests/ghci/scripts/T9293.script b/testsuite/tests/ghci/scripts/T9293.script
new file mode 100644
index 0000000000..c2fbf46cd7
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9293.script
@@ -0,0 +1,27 @@
+:set
+
+putStrLn "Should fail, GADTs is not enabled"
+data T a where C :: T Int
+
+:set -XGADTs
+:set
+
+putStrLn "Should work, GADTs is in force from :set"
+:load ghci057.hs
+
+:unset -XGADTs
+:set
+
+putStrLn "Should fail, GADTs is now disabled"
+:load ghci057.hs
+
+:seti -XGADTs
+:seti
+
+putStrLn "Should fail, GADTs is only enabled at the prompt"
+:load ghci057.hs
+
+-- Should work
+data T a where C :: T Int
+:t C
+
diff --git a/testsuite/tests/ghci/scripts/T9293.stderr b/testsuite/tests/ghci/scripts/T9293.stderr
new file mode 100644
index 0000000000..089704d9b4
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9293.stderr
@@ -0,0 +1,19 @@
+
+<interactive>:5:1:
+ Illegal generalised algebraic data declaration for ‘T’
+ (Use GADTs to allow GADTs)
+ In the data declaration for ‘T’
+
+ghci057.hs:3:3:
+ Data constructor ‘C’ has existential type variables, a context, or a specialised result type
+ C :: T Int
+ (Use ExistentialQuantification or GADTs to allow this)
+ In the definition of data constructor ‘C’
+ In the data declaration for ‘T’
+
+ghci057.hs:3:3:
+ Data constructor ‘C’ has existential type variables, a context, or a specialised result type
+ C :: T Int
+ (Use ExistentialQuantification or GADTs to allow this)
+ In the definition of data constructor ‘C’
+ In the data declaration for ‘T’
diff --git a/testsuite/tests/ghci/scripts/T9293.stdout b/testsuite/tests/ghci/scripts/T9293.stdout
new file mode 100644
index 0000000000..67fc63058e
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T9293.stdout
@@ -0,0 +1,54 @@
+options currently set: none.
+base language is: Haskell2010
+with the following modifiers:
+ -XNoDatatypeContexts
+ -XNondecreasingIndentation
+GHCi-specific dynamic flag settings:
+other dynamic, non-language, flag settings:
+ -fno-ghci-history
+ -fimplicit-import-qualified
+warning settings:
+Should fail, GADTs is not enabled
+options currently set: none.
+base language is: Haskell2010
+with the following modifiers:
+ -XNoDatatypeContexts
+ -XGADTSyntax
+ -XGADTs
+ -XMonoLocalBinds
+ -XNondecreasingIndentation
+GHCi-specific dynamic flag settings:
+other dynamic, non-language, flag settings:
+ -fno-ghci-history
+ -fimplicit-import-qualified
+warning settings:
+Should work, GADTs is in force from :set
+options currently set: none.
+base language is: Haskell2010
+with the following modifiers:
+ -XNoDatatypeContexts
+ -XGADTSyntax
+ -XMonoLocalBinds
+ -XNondecreasingIndentation
+GHCi-specific dynamic flag settings:
+other dynamic, non-language, flag settings:
+ -fno-ghci-history
+ -fimplicit-import-qualified
+warning settings:
+Should fail, GADTs is now disabled
+base language is: Haskell2010
+with the following modifiers:
+ -XNoDatatypeContexts
+ -XExtendedDefaultRules
+ -XGADTSyntax
+ -XGADTs
+ -XMonoLocalBinds
+ -XNoMonomorphismRestriction
+ -XNondecreasingIndentation
+GHCi-specific dynamic flag settings:
+other dynamic, non-language, flag settings:
+ -fno-ghci-history
+ -fimplicit-import-qualified
+warning settings:
+Should fail, GADTs is only enabled at the prompt
+C :: T Int
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 624f4310c1..12bfebf814 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -190,3 +190,4 @@ test('T9181', normal, ghci_script, ['T9181.script'])
test('T9086b', normal, ghci_script, ['T9086b.script'])
test('T9140', combined_output, ghci_script, ['T9140.script'])
test('T9658', normal, ghci_script, ['T9658.script'])
+test('T9293', normal, ghci_script_without_flag('-fno-warn-tabs'), ['T9293.script'])
diff --git a/testsuite/tests/safeHaskell/ghci/p12.stderr b/testsuite/tests/safeHaskell/ghci/p12.stderr
index fc43305e11..3b259c3722 100644
--- a/testsuite/tests/safeHaskell/ghci/p12.stderr
+++ b/testsuite/tests/safeHaskell/ghci/p12.stderr
@@ -1,7 +1,7 @@
-don't know how to reverse -XSafe
+Some flags have not been recognized: -XNoSafe
Some flags have not been recognized: -fno-package-trust
<no location info>:
Data.ByteString: Can't be safely imported!
- The package (bytestring-0.10.1.0) the module resides in isn't trusted.
+ The package (bytestring-0.10.5.0) the module resides in isn't trusted.
diff --git a/testsuite/tests/safeHaskell/ghci/p5.stderr b/testsuite/tests/safeHaskell/ghci/p5.stderr
index 3f649f7b60..7e70988612 100644
--- a/testsuite/tests/safeHaskell/ghci/p5.stderr
+++ b/testsuite/tests/safeHaskell/ghci/p5.stderr
@@ -1,7 +1,7 @@
-don't know how to reverse -XSafe
+Some flags have not been recognized: -XNoSafe
ghc-stage2: <no location info>: Incompatible Safe Haskell flags! (Safe, Trustworthy)
Usage: For basic information, try the `--help' option.
-don't know how to reverse -XTrustworthy
+Some flags have not been recognized: -XNoTrustworthy
ghc-stage2: <no location info>: Incompatible Safe Haskell flags! (Safe, Unsafe)
Usage: For basic information, try the `--help' option.
-don't know how to reverse -XUnsafe
+Some flags have not been recognized: -XNoUnsafe