Commit 9fb744bd authored by Roland Senn's avatar Roland Senn Committed by Ben Gamari

GHCi ignores cmd line flags XMonomorphismRestr.. XNoExtendedDef..#10857

parent ce2f77d5
......@@ -34,6 +34,7 @@ module DynFlags (
wopt, wopt_set, wopt_unset,
wopt_fatal, wopt_set_fatal, wopt_unset_fatal,
xopt, xopt_set, xopt_unset,
xopt_set_unlessExplSpec,
lang_set,
useUnicodeSyntax,
useStarIsType,
......@@ -1077,6 +1078,9 @@ data DynFlags = DynFlags {
warnUnsafeOnLoc :: SrcSpan,
trustworthyOnLoc :: SrcSpan,
-- Don't change this without updating extensionFlags:
-- Here we collect the settings of the language extensions
-- from the command line, the ghci config file and
-- from interactive :set / :seti commands.
extensions :: [OnOff LangExt.Extension],
-- extensionFlags should always be equal to
-- flattenExtensionFlags language extensions
......@@ -2378,6 +2382,19 @@ xopt_unset dfs f
in dfs { extensions = onoffs,
extensionFlags = flattenExtensionFlags (language dfs) onoffs }
-- | Set or unset a 'LangExt.Extension', unless it has been explicitely
-- set or unset before.
xopt_set_unlessExplSpec
:: LangExt.Extension
-> (DynFlags -> LangExt.Extension -> DynFlags)
-> DynFlags -> DynFlags
xopt_set_unlessExplSpec ext setUnset dflags =
let referedExts = stripOnOff <$> extensions dflags
stripOnOff (On x) = x
stripOnOff (Off x) = x
in
if ext `elem` referedExts then dflags else setUnset dflags ext
lang_set :: DynFlags -> Maybe Language -> DynFlags
lang_set dflags lang =
dflags {
......
......@@ -433,9 +433,17 @@ interactiveUI config srcs maybe_exprs = do
-- The initial set of DynFlags used for interactive evaluation is the same
-- as the global DynFlags, plus -XExtendedDefaultRules and
-- -XNoMonomorphismRestriction.
-- However we set/unset these two extensions only, if they were not already
-- explicitely specified before. The function 'xopt_set_unlessExplSpec'
-- inspects the data field DynFlags.extensions.
-- At this point of the GHCi initialization this data field contains only
-- the extensions specified at the command line.
-- The ghci config file has not yet been processed. (#10857)
dflags <- getDynFlags
let dflags' = (`xopt_set` LangExt.ExtendedDefaultRules)
. (`xopt_unset` LangExt.MonomorphismRestriction)
let dflags' = (xopt_set_unlessExplSpec
LangExt.ExtendedDefaultRules xopt_set)
. (xopt_set_unlessExplSpec
LangExt.MonomorphismRestriction xopt_unset)
$ dflags
GHC.setInteractiveDynFlags dflags'
......
base language is: Haskell2010
with the following modifiers:
-XNoDatatypeContexts
-XExtendedDefaultRules
-XNoMonomorphismRestriction
-XNondecreasingIndentation
base language is: Haskell2010
with the following modifiers:
-XNoDatatypeContexts
-XNondecreasingIndentation
......@@ -23,6 +23,10 @@ test('T9914', just_ghci, ghci_script, ['T9914.script'])
test('T9915', just_ghci, ghci_script, ['T9915.script'])
test('T10145', just_ghci, ghci_script, ['T10145.script'])
test('T7253', just_ghci, ghci_script, ['T7253.script'])
test('T10857a', just_ghci, ghci_script, ['T10857a.script'])
test('T10857b',
[extra_hc_opts("-XMonomorphismRestriction -XNoExtendedDefaultRules")],
ghci_script, ['T10857b.script'])
test('T11328', just_ghci, ghci_script, ['T11328.script'])
test('T11825', just_ghci, ghci_script, ['T11825.script'])
test('T12128', just_ghci, ghci_script, ['T12128.script'])
......
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