Refactor GHCi UI to fix #11606, #12091, #15721, #16096
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Wed, 9 Jan 2019 15:44:48 +0000 (18:44 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Sun, 13 Jan 2019 05:17:20 +0000 (00:17 -0500)
commita34ee61545930d569d0dbafb3a4a5db3a7a711e5
tree940ad55163a9c12a97b15a529d7a2c57a8efef7a
parent448f0e7dd78a8d9404f1aa5e8522cc284360c06d
Refactor GHCi UI to fix #11606, #12091, #15721, #16096

Instead of parsing and executing a statement or declaration directly we
now parse them first and then execute in a separate step. This gives us
the flexibility to inspect the parsed declaration before execution.
Using this we now inspect parsed declarations, and if it's a single
declaration of form `x = y` we execute it as `let x = y` instead, fixing
a ton of problems caused by poor declaration support in GHCi.

To avoid any users of the modules I left `execStmt` and `runDecls`
unchanged and added `execStmt'` and `runDecls'` which work on parsed
statements/declarations.
16 files changed:
compiler/deSugar/Desugar.hs
compiler/main/GHC.hs
compiler/main/HscMain.hs
compiler/main/HscTypes.hs
compiler/main/InteractiveEval.hs
ghc/GHCi/UI.hs
ghc/GHCi/UI/Monad.hs
testsuite/tests/ghci/scripts/T11606.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T11606.stderr [new file with mode: 0644]
testsuite/tests/ghci/scripts/T16089.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T16089.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T
testsuite/tests/ghci/should_run/T12525.stdout
testsuite/tests/ghci/should_run/T16096.script [new file with mode: 0644]
testsuite/tests/ghci/should_run/T16096.stdout [new file with mode: 0644]
testsuite/tests/ghci/should_run/all.T