diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-01-09 18:44:48 +0300 |
---|---|---|
committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-01-13 00:17:20 -0500 |
commit | a34ee61545930d569d0dbafb3a4a5db3a7a711e5 (patch) | |
tree | 940ad55163a9c12a97b15a529d7a2c57a8efef7a /testsuite/tests | |
parent | 448f0e7dd78a8d9404f1aa5e8522cc284360c06d (diff) | |
download | haskell-a34ee61545930d569d0dbafb3a4a5db3a7a711e5.tar.gz |
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.
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/ghci/scripts/T11606.script | 5 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T11606.stderr | 12 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T16089.script | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T16089.stdout | 3 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/should_run/T12525.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/should_run/T16096.script | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/should_run/T16096.stdout | 56 | ||||
-rw-r--r-- | testsuite/tests/ghci/should_run/all.T | 2 |
9 files changed, 90 insertions, 2 deletions
diff --git a/testsuite/tests/ghci/scripts/T11606.script b/testsuite/tests/ghci/scripts/T11606.script new file mode 100644 index 0000000000..0fb5fff7ad --- /dev/null +++ b/testsuite/tests/ghci/scripts/T11606.script @@ -0,0 +1,5 @@ +:set -Wall +x = 1 :: Int +x = 1 :: Int +x <- return (1 :: Int) +let x = 1 :: Int diff --git a/testsuite/tests/ghci/scripts/T11606.stderr b/testsuite/tests/ghci/scripts/T11606.stderr new file mode 100644 index 0000000000..bbfb7406c6 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T11606.stderr @@ -0,0 +1,12 @@ + +<interactive>:3:1: warning: [-Wname-shadowing (in -Wall)] + This binding for ‘x’ shadows the existing binding + defined at <interactive>:2:1 + +<interactive>:4:1: warning: [-Wname-shadowing (in -Wall)] + This binding for ‘x’ shadows the existing binding + defined at <interactive>:3:1 + +<interactive>:5:5: warning: [-Wname-shadowing (in -Wall)] + This binding for ‘x’ shadows the existing binding + defined at <interactive>:4:1 diff --git a/testsuite/tests/ghci/scripts/T16089.script b/testsuite/tests/ghci/scripts/T16089.script new file mode 100644 index 0000000000..d4e6676244 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T16089.script @@ -0,0 +1,4 @@ +x = [0 .. 100000] :: [Int] +:sprint x +x `seq` True +:sprint x diff --git a/testsuite/tests/ghci/scripts/T16089.stdout b/testsuite/tests/ghci/scripts/T16089.stdout new file mode 100644 index 0000000000..7d5cc0b192 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T16089.stdout @@ -0,0 +1,3 @@ +x = _ +True +x = 0 : _ diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index ad4a24f583..2567db4f3d 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -262,7 +262,7 @@ test('T12091', [extra_run_opts('-fobject-code')], ghci_script, ['T12091.script']) test('T12523', normal, ghci_script, ['T12523.script']) test('T12024', normal, ghci_script, ['T12024.script']) -test('T12158', expect_broken(12158), ghci_script, ['T12158.script']) +test('T12158', normal, ghci_script, ['T12158.script']) test('T12447', normal, ghci_script, ['T12447.script']) test('T10249', normal, ghci_script, ['T10249.script']) test('T12550', normal, ghci_script, ['T12550.script']) @@ -293,3 +293,5 @@ test('T15827', normal, ghci_script, ['T15827.script']) test('T15898', normal, ghci_script, ['T15898.script']) test('T15941', normal, ghci_script, ['T15941.script']) test('T16030', normal, ghci_script, ['T16030.script']) +test('T11606', normal, ghci_script, ['T11606.script']) +test('T16089', normal, ghci_script, ['T16089.script']) diff --git a/testsuite/tests/ghci/should_run/T12525.stdout b/testsuite/tests/ghci/should_run/T12525.stdout index 31049e14d1..652a5cdd03 100644 --- a/testsuite/tests/ghci/should_run/T12525.stdout +++ b/testsuite/tests/ghci/should_run/T12525.stdout @@ -1,3 +1,3 @@ -x :: () = _ +x :: () = () y :: () = () class Foo a diff --git a/testsuite/tests/ghci/should_run/T16096.script b/testsuite/tests/ghci/should_run/T16096.script new file mode 100644 index 0000000000..8fb9453fd8 --- /dev/null +++ b/testsuite/tests/ghci/should_run/T16096.script @@ -0,0 +1,4 @@ +:set -ddump-ds -dsuppress-uniques +-- These two should desugar to same Core +let x = [1..] :: [Int] +x = [1..] :: [Int] diff --git a/testsuite/tests/ghci/should_run/T16096.stdout b/testsuite/tests/ghci/should_run/T16096.stdout new file mode 100644 index 0000000000..8b87b7d61c --- /dev/null +++ b/testsuite/tests/ghci/should_run/T16096.stdout @@ -0,0 +1,56 @@ + +==================== Desugared ==================== +letrec { + x :: [GHC.Types.Int] + [LclId] + x = let { + $dEnum :: GHC.Enum.Enum GHC.Types.Int + [LclId] + $dEnum = GHC.Enum.$fEnumInt } in + letrec { + x :: [GHC.Types.Int] + [LclId] + x = GHC.Enum.enumFrom + @ GHC.Types.Int $dEnum (GHC.Types.I# 1#); } in + x; } in +GHC.Base.returnIO + @ [()] + (GHC.Types.: + @ () + (GHC.Prim.unsafeCoerce# + @ 'GHC.Types.LiftedRep + @ 'GHC.Types.LiftedRep + @ [GHC.Types.Int] + @ () + x) + (GHC.Types.[] @ ())) + + + +==================== Desugared ==================== +letrec { + x :: [GHC.Types.Int] + [LclId] + x = let { + $dEnum :: GHC.Enum.Enum GHC.Types.Int + [LclId] + $dEnum = GHC.Enum.$fEnumInt } in + letrec { + x :: [GHC.Types.Int] + [LclId] + x = GHC.Enum.enumFrom + @ GHC.Types.Int $dEnum (GHC.Types.I# 1#); } in + x; } in +GHC.Base.returnIO + @ [()] + (GHC.Types.: + @ () + (GHC.Prim.unsafeCoerce# + @ 'GHC.Types.LiftedRep + @ 'GHC.Types.LiftedRep + @ [GHC.Types.Int] + @ () + x) + (GHC.Types.[] @ ())) + + diff --git a/testsuite/tests/ghci/should_run/all.T b/testsuite/tests/ghci/should_run/all.T index ea734e74aa..004794b5e5 100644 --- a/testsuite/tests/ghci/should_run/all.T +++ b/testsuite/tests/ghci/should_run/all.T @@ -56,3 +56,5 @@ test('T15633b', extra_hc_opts("-package-db tc-plugin-ghci/pkg.plugins01/local.package.conf") ], ghci_script, ['T15633b.script']) + +test('T16096', just_ghci, ghci_script, ['T16096.script']) |