[commit: ghc] ghc-8.6: API Annotations when parsing typapp (4cfeca0)

git at git.haskell.org git at git.haskell.org
Wed Jun 27 21:09:42 UTC 2018


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

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/4cfeca02a0a9283e8c9f9ccd9373bc1f2fd8db0a/ghc

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

commit 4cfeca02a0a9283e8c9f9ccd9373bc1f2fd8db0a
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date:   Tue Jun 26 11:07:07 2018 +0200

    API Annotations when parsing typapp
    
    Make sure the original annotations are still accessible for a promoted
    type.
    
    Closes #15303
    
    (cherry picked from commit e53c113dcfeca9ee957722ede3d8b6a2c4c751a1)


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

4cfeca02a0a9283e8c9f9ccd9373bc1f2fd8db0a
 compiler/parser/Parser.y                          |  4 +--
 testsuite/tests/ghc-api/annotations/Makefile      |  4 +++
 testsuite/tests/ghc-api/annotations/T15303.stdout | 35 +++++++++++++++++++++++
 testsuite/tests/ghc-api/annotations/Test15303.hs  |  6 ++++
 testsuite/tests/ghc-api/annotations/all.T         |  2 ++
 5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 6b0317b..d038562 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -1930,9 +1930,9 @@ tyapp :: { Located TyEl }
         | qtyconop                      { sL1 $1 $ TyElOpr (unLoc $1) }
         | tyvarop                       { sL1 $1 $ TyElOpr (unLoc $1) }
         | SIMPLEQUOTE qconop            {% ams (sLL $1 $> $ TyElOpr (unLoc $2))
-                                               [mj AnnSimpleQuote $1] }
+                                               [mj AnnSimpleQuote $1,mj AnnVal $2] }
         | SIMPLEQUOTE varop             {% ams (sLL $1 $> $ TyElOpr (unLoc $2))
-                                               [mj AnnSimpleQuote $1] }
+                                               [mj AnnSimpleQuote $1,mj AnnVal $2] }
 
 atype_docs :: { LHsType GhcPs }
         : atype docprev                 { sLL $1 $> $ HsDocTy noExt $1 $2 }
diff --git a/testsuite/tests/ghc-api/annotations/Makefile b/testsuite/tests/ghc-api/annotations/Makefile
index 2da5fc0..98b4574 100644
--- a/testsuite/tests/ghc-api/annotations/Makefile
+++ b/testsuite/tests/ghc-api/annotations/Makefile
@@ -141,3 +141,7 @@ T12417:
 .PHONY: T13163
 T13163:
 	$(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test13163.hs
+
+.PHONY: T15303
+T15303:
+	$(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test15303.hs
diff --git a/testsuite/tests/ghc-api/annotations/T15303.stdout b/testsuite/tests/ghc-api/annotations/T15303.stdout
new file mode 100644
index 0000000..003dab5
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/T15303.stdout
@@ -0,0 +1,35 @@
+---Problems (should be empty list)---
+[]
+---Annotations-----------------------
+-- SrcSpan the annotation is attached to, AnnKeywordId,
+--    list of locations the keyword item appears in
+[
+((Test15303.hs:4:1-4,AnnCloseP), [Test15303.hs:4:4]),
+((Test15303.hs:4:1-4,AnnOpenP), [Test15303.hs:4:1]),
+((Test15303.hs:4:1-4,AnnVal), [Test15303.hs:4:2-3]),
+((Test15303.hs:4:1-66,AnnDcolon), [Test15303.hs:4:6-7]),
+((Test15303.hs:4:1-66,AnnSemi), [Test15303.hs:5:1]),
+((Test15303.hs:4:9-17,AnnDarrow), [Test15303.hs:4:19-20]),
+((Test15303.hs:4:22-41,AnnRarrow), [Test15303.hs:4:43-44]),
+((Test15303.hs:4:22-66,AnnRarrow), [Test15303.hs:4:43-44]),
+((Test15303.hs:4:33-41,AnnCloseP), [Test15303.hs:4:41]),
+((Test15303.hs:4:33-41,AnnOpenP), [Test15303.hs:4:33]),
+((Test15303.hs:4:36-37,AnnSimpleQuote), [Test15303.hs:4:36]),
+((Test15303.hs:4:36-37,AnnVal), [Test15303.hs:4:37]),
+((Test15303.hs:4:46-48,AnnRarrow), [Test15303.hs:4:50-51]),
+((Test15303.hs:4:46-66,AnnRarrow), [Test15303.hs:4:50-51]),
+((Test15303.hs:4:58-66,AnnCloseP), [Test15303.hs:4:66]),
+((Test15303.hs:4:58-66,AnnOpenP), [Test15303.hs:4:58]),
+((Test15303.hs:4:61-62,AnnSimpleQuote), [Test15303.hs:4:61]),
+((Test15303.hs:4:61-62,AnnVal), [Test15303.hs:4:62]),
+((Test15303.hs:5:1-4,AnnCloseP), [Test15303.hs:5:4]),
+((Test15303.hs:5:1-4,AnnOpenP), [Test15303.hs:5:1]),
+((Test15303.hs:5:1-4,AnnVal), [Test15303.hs:5:2-3]),
+((Test15303.hs:5:1-15,AnnEqual), [Test15303.hs:5:6]),
+((Test15303.hs:5:1-15,AnnFunId), [Test15303.hs:5:1-4]),
+((Test15303.hs:5:1-15,AnnSemi), [Test15303.hs:6:1]),
+((Test15303.hs:6:1-11,AnnInfix), [Test15303.hs:6:1-6]),
+((Test15303.hs:6:1-11,AnnSemi), [Test15303.hs:7:1]),
+((Test15303.hs:6:1-11,AnnVal), [Test15303.hs:6:8]),
+((<no location info>,AnnEofPos), [Test15303.hs:7:1])
+]
diff --git a/testsuite/tests/ghc-api/annotations/Test15303.hs b/testsuite/tests/ghc-api/annotations/Test15303.hs
new file mode 100644
index 0000000..212e9da
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/Test15303.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE DataKinds              #-}
+{-# LANGUAGE TypeOperators          #-}
+
+(~#) :: Comonad w => CascadeW w (t ': ts) -> w t -> Last (t ': ts)
+(~#) = cascadeW
+infixr 0 ~#
diff --git a/testsuite/tests/ghc-api/annotations/all.T b/testsuite/tests/ghc-api/annotations/all.T
index adc0d14..666cb3f 100644
--- a/testsuite/tests/ghc-api/annotations/all.T
+++ b/testsuite/tests/ghc-api/annotations/all.T
@@ -57,3 +57,5 @@ test('T12417',      [extra_files(['Test12417.hs']),
                      ignore_stderr], run_command, ['$MAKE -s --no-print-directory T12417'])
 test('T13163',      [extra_files(['Test13163.hs']),
                      ignore_stderr], run_command, ['$MAKE -s --no-print-directory T13163'])
+test('T15303',      [extra_files(['Test15303.hs']),
+                     ignore_stderr], run_command, ['$MAKE -s --no-print-directory T15303'])



More information about the ghc-commits mailing list