[commit: ghc] ghc-8.2: Make GHCi work when RebindableSyntax is enabled (c89ef44)

git at git.haskell.org git at git.haskell.org
Mon Jun 19 13:03:32 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/c89ef44bbf8c11fca9a12d8fc52c57b382055630/ghc

>---------------------------------------------------------------

commit c89ef44bbf8c11fca9a12d8fc52c57b382055630
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Fri Jun 2 11:49:47 2017 -0400

    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
    
    (cherry picked from commit 2abe54e16cbd14cab27abdc7967e907753354d54)


>---------------------------------------------------------------

c89ef44bbf8c11fca9a12d8fc52c57b382055630
 ghc/GHCi/UI/Monad.hs                                         | 12 +++++++-----
 .../tests/ghci/scripts/T13385.script                         |  0
 testsuite/tests/ghci/scripts/all.T                           |  1 +
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs
index 244595b..b57a5a0 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/libraries/ghc-compact/tests/compact_serialize.stderr b/testsuite/tests/ghci/scripts/T13385.script
similarity index 100%
copy from libraries/ghc-compact/tests/compact_serialize.stderr
copy to testsuite/tests/ghci/scripts/T13385.script
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 77b611a..71f812f 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -251,5 +251,6 @@ 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('T13466', normal, ghci_script, ['T13466.script'])
 test('GhciCurDir', normal, ghci_script, ['GhciCurDir.script'])



More information about the ghc-commits mailing list