summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Price <2855417+ElderEphemera@users.noreply.github.com>2020-05-22 23:57:56 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-27 00:15:17 -0400
commitd6203f24cf421749616a247c047a9b44192f963a (patch)
treed6b6f9a114b79367d5943e3963fdd26c390fa3a4
parent04750304deae2128a8350e28224e1f62ae949820 (diff)
downloadhaskell-d6203f24cf421749616a247c047a9b44192f963a.tar.gz
Make `identifier` parse unparenthesized `->` (#18060)
-rw-r--r--compiler/GHC/Parser.y2
-rw-r--r--testsuite/tests/ghci/T18060/T18060.script2
-rw-r--r--testsuite/tests/ghci/T18060/T18060.stdout12
-rw-r--r--testsuite/tests/ghci/T18060/all.T1
4 files changed, 17 insertions, 0 deletions
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y
index 00ea6fbda8..6dde13f7a9 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -644,6 +644,8 @@ identifier :: { Located RdrName }
| qconop { $1 }
| '(' '->' ')' {% ams (sLL $1 $> $ getRdrName funTyCon)
[mop $1,mu AnnRarrow $2,mcp $3] }
+ | '->' {% ams (sLL $1 $> $ getRdrName funTyCon)
+ [mu AnnRarrow $1] }
-----------------------------------------------------------------------------
-- Backpack stuff
diff --git a/testsuite/tests/ghci/T18060/T18060.script b/testsuite/tests/ghci/T18060/T18060.script
new file mode 100644
index 0000000000..1206525a47
--- /dev/null
+++ b/testsuite/tests/ghci/T18060/T18060.script
@@ -0,0 +1,2 @@
+:i ->
+:i ~
diff --git a/testsuite/tests/ghci/T18060/T18060.stdout b/testsuite/tests/ghci/T18060/T18060.stdout
new file mode 100644
index 0000000000..9d6ab23dba
--- /dev/null
+++ b/testsuite/tests/ghci/T18060/T18060.stdout
@@ -0,0 +1,12 @@
+type (->) :: * -> * -> *
+data (->) a b
+ -- Defined in ‘GHC.Prim’
+infixr -1 ->
+instance Applicative ((->) r) -- Defined in ‘GHC.Base’
+instance Functor ((->) r) -- Defined in ‘GHC.Base’
+instance Monad ((->) r) -- Defined in ‘GHC.Base’
+instance Monoid b => Monoid (a -> b) -- Defined in ‘GHC.Base’
+instance Semigroup b => Semigroup (a -> b) -- Defined in ‘GHC.Base’
+type (~) :: forall k. k -> k -> Constraint
+class (a ~ b) => (~) a b
+ -- Defined in ‘GHC.Types’
diff --git a/testsuite/tests/ghci/T18060/all.T b/testsuite/tests/ghci/T18060/all.T
new file mode 100644
index 0000000000..5d6cf4299f
--- /dev/null
+++ b/testsuite/tests/ghci/T18060/all.T
@@ -0,0 +1 @@
+test('T18060', normal, ghci_script, ['T18060.script'])