Fixes ghci :unset -X<ext> so that it doesn't fail to reverse option. (fixes trac...
authorMuhaimin Ahsan <leroux@fezrev.com>
Fri, 21 Nov 2014 17:31:44 +0000 (11:31 -0600)
committerAustin Seipp <austin@well-typed.com>
Fri, 21 Nov 2014 17:31:45 +0000 (11:31 -0600)
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

ghc/InteractiveUI.hs
testsuite/tests/ghci/scripts/T9293.hs [new file with mode: 0644]
testsuite/tests/ghci/scripts/T9293.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T9293.stderr [new file with mode: 0644]
testsuite/tests/ghci/scripts/T9293.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T
testsuite/tests/safeHaskell/ghci/p12.stderr
testsuite/tests/safeHaskell/ghci/p5.stderr

index f5a1bbe..7fdda0b 100644 (file)
@@ -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 (file)
index 0000000..f7329c9
--- /dev/null
@@ -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 (file)
index 0000000..c2fbf46
--- /dev/null
@@ -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 (file)
index 0000000..089704d
--- /dev/null
@@ -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 (file)
index 0000000..67fc630
--- /dev/null
@@ -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
index 624f431..12bfebf 100755 (executable)
@@ -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'])
index fc43305..3b259c3 100644 (file)
@@ -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.
 
index 3f649f7..7e70988 100644 (file)
@@ -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