summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-06-02 11:49:47 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-02 12:27:45 -0400
commit2abe54e16cbd14cab27abdc7967e907753354d54 (patch)
treefec7e858402af6cd681cfb787182fbd65ca301f1
parentbf775e9d6895c07f629409ee18503f40730cb5a0 (diff)
downloadhaskell-2abe54e16cbd14cab27abdc7967e907753354d54.tar.gz
Make GHCi work when RebindableSyntax is enabled
Previously, we were running some blocks of code at the start of every GHCi sessions which use do-notation, something which doesn't work well if you start GHCi with the `-XRebindableSyntax` flag on. This tweaks the code to avoid the use of do-notation so that `-XRebindableSyntax` won't reject it. Test Plan: make test TEST=T13385 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13385 Differential Revision: https://phabricator.haskell.org/D3621
-rw-r--r--ghc/GHCi/UI/Monad.hs12
-rw-r--r--testsuite/tests/ghci/scripts/T13385.script0
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
3 files changed, 8 insertions, 5 deletions
diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs
index 244595b8b0..b57a5a0a64 100644
--- a/ghc/GHCi/UI/Monad.hs
+++ b/ghc/GHCi/UI/Monad.hs
@@ -420,13 +420,15 @@ foreign import ccall "revertCAFs" rts_revertCAFs :: IO ()
-- | Compile "hFlush stdout; hFlush stderr" once, so we can use it repeatedly
initInterpBuffering :: Ghc (ForeignHValue, ForeignHValue)
initInterpBuffering = do
+ -- We take great care not to use do-notation in the expressions below, as
+ -- they are fragile in the presence of RebindableSyntax (Trac #13385).
nobuf <- GHC.compileExprRemote $
- "do { System.IO.hSetBuffering System.IO.stdin System.IO.NoBuffering; " ++
- " System.IO.hSetBuffering System.IO.stdout System.IO.NoBuffering; " ++
- " System.IO.hSetBuffering System.IO.stderr System.IO.NoBuffering }"
+ " System.IO.hSetBuffering System.IO.stdin System.IO.NoBuffering" ++
+ "`GHC.Base.thenIO` System.IO.hSetBuffering System.IO.stdout System.IO.NoBuffering" ++
+ "`GHC.Base.thenIO` System.IO.hSetBuffering System.IO.stderr System.IO.NoBuffering"
flush <- GHC.compileExprRemote $
- "do { System.IO.hFlush System.IO.stdout; " ++
- " System.IO.hFlush System.IO.stderr }"
+ " System.IO.hFlush System.IO.stdout" ++
+ "`GHC.Base.thenIO` System.IO.hFlush System.IO.stderr"
return (nobuf, flush)
-- | Invoke "hFlush stdout; hFlush stderr" in the interpreter
diff --git a/testsuite/tests/ghci/scripts/T13385.script b/testsuite/tests/ghci/scripts/T13385.script
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T13385.script
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 8ef45fe381..8c3a2f55ee 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -251,6 +251,7 @@ test('T12550', normal, ghci_script, ['T12550.script'])
test('StaticPtr', normal, ghci_script, ['StaticPtr.script'])
test('T13202', normal, ghci_script, ['T13202.script'])
test('T13202a', normal, ghci_script, ['T13202a.script'])
+test('T13385', [extra_hc_opts("-XRebindableSyntax")], ghci_script, ['T13385.script'])
test('T13420', normal, ghci_script, ['T13420.script'])
test('T13466', normal, ghci_script, ['T13466.script'])
test('GhciCurDir', normal, ghci_script, ['GhciCurDir.script'])