Turned off language extension from GHCi prompt affects SafeHaskell status of loaded file
Summary
Ever turning on an unsafe language flag (even turning it off again) on GHCi affectes the status of loaded files.
This is one of the blockers for updating the test suite in !4853 (closed).
Steps to reproduce
/tmp $ cat Foo.hs
module Foo where
class A a
instance A Int
/tmp $ ghci-8.10
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> :load Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, interpreted )
Ok, one module loaded.
*Foo> :info A
type A :: * -> Constraint
class A a
-- Defined at Foo.hs:2:1
instance [safe] A Int -- Defined at Foo.hs:3:10
*Foo>
Leaving GHCi.
Note that the instance is [safe]
.
/tmp $ ghci-8.10
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> :set -XGeneralizedNewtypeDeriving
Prelude> :load Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, interpreted )
Ok, one module loaded.
*Foo> :info A
type A :: * -> Constraint
class A a
-- Defined at Foo.hs:2:1
instance A Int -- Defined at Foo.hs:3:10
*Foo>
Leaving GHCi.
And now it is not.
That is expected: :set
affects loaded files (and with :seti
they would not).
But: Turning it off again still has that behavior:
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> :set -XGeneralizedNewtypeDeriving
Prelude> :set -XNoGeneralizedNewtypeDeriving
Prelude> :load Foo
[1 of 1] Compiling Foo ( Foo.hs, interpreted )
Ok, one module loaded.
*Foo> :info A
type A :: * -> Constraint
class A a
-- Defined at Foo.hs:2:1
instance A Int -- Defined at Foo.hs:3:10
This is with GHC-8.10, but as !4853 (closed) shows it’s a problem in master
as well.