Commit 3e4f49b0 authored by leroux's avatar leroux Committed by Austin Seipp
Browse files

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
parent 803fc5db
......@@ -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))
......
module Test where
data T a where
C :: T Int
: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
<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’
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
......@@ -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'])
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.
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment