[commit: ghc] wip/api-annots: ApiAnnotations : PatBind gives wrong SrcSpan for the pattern. (c25168b)

git at git.haskell.org git at git.haskell.org
Sat May 9 14:17:56 UTC 2015


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

On branch  : wip/api-annots
Link       : http://ghc.haskell.org/trac/ghc/changeset/c25168bd9a4fd5d0acb8c83cad07d56c36cd8f6f/ghc

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

commit c25168bd9a4fd5d0acb8c83cad07d56c36cd8f6f
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date:   Fri May 8 12:10:28 2015 +0200

    ApiAnnotations : PatBind gives wrong SrcSpan for the pattern.
    
    Summary:
    The production for decl_no_th starts
    
        decl_no_th :: { Located (OrdList (LHsDecl RdrName)) }
                : sigdecl               { $1 }
    
                | '!' aexp rhs          {% do { let { e = sLL $1 $> (SectionR (sL1 $1 (HsVar bang_RDR)) $2) };
                                                pat <- checkPattern empty e;
        ...
    
    The e value should be just the pattern, excluding the rhs, but the span
    created includes the rhs.
    
    Test Plan: ./validate
    
    Reviewers: hvr, austin
    
    Subscribers: bgamari, thomie, mpickering
    
    Differential Revision: https://phabricator.haskell.org/D873
    
    GHC Trac Issues: #10358
    
    Conflicts:
    	testsuite/tests/ghc-api/annotations/.gitignore
    	testsuite/tests/ghc-api/annotations/all.T


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

c25168bd9a4fd5d0acb8c83cad07d56c36cd8f6f
 compiler/parser/Parser.y                           |  4 +-
 testsuite/tests/ghc-api/annotations/.gitignore     |  1 +
 testsuite/tests/ghc-api/annotations/Makefile       |  7 +++
 testsuite/tests/ghc-api/annotations/T10358.stdout  | 58 ++++++++++++++++++++++
 testsuite/tests/ghc-api/annotations/Test10358.hs   |  8 +++
 testsuite/tests/ghc-api/annotations/all.T          |  1 +
 .../ghc-api/annotations/{t10357.hs => t10358.hs}   |  2 +-
 7 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 51b20a0..eb2aa0c 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -1986,10 +1986,10 @@ docdecld :: { LDocDecl }
 decl_no_th :: { Located (OrdList (LHsDecl RdrName)) }
         : sigdecl               { $1 }
 
-        | '!' aexp rhs          {% do { let { e = sLL $1 $> (SectionR (sL1 $1 (HsVar bang_RDR)) $2) };
+        | '!' aexp rhs          {% do { let { e = sLL $1 $2 (SectionR (sL1 $1 (HsVar bang_RDR)) $2) };
                                         pat <- checkPattern empty e;
                                         _ <- ams (sLL $1 $> ())
-                                               (mj AnnBang $1:(fst $ unLoc $3));
+                                               (fst $ unLoc $3);
                                         return $ sLL $1 $> $ unitOL $ sLL $1 $> $ ValD $
                                             PatBind pat (snd $ unLoc $3)
                                                     placeHolderType
diff --git a/testsuite/tests/ghc-api/annotations/.gitignore b/testsuite/tests/ghc-api/annotations/.gitignore
index 4f6f3be..b8bba4f 100644
--- a/testsuite/tests/ghc-api/annotations/.gitignore
+++ b/testsuite/tests/ghc-api/annotations/.gitignore
@@ -5,6 +5,7 @@ exampleTest
 listcomps
 t10309
 t10357
+t10358
 t10255
 t10268
 t10269
diff --git a/testsuite/tests/ghc-api/annotations/Makefile b/testsuite/tests/ghc-api/annotations/Makefile
index 0cebeaf..7cf7baf 100644
--- a/testsuite/tests/ghc-api/annotations/Makefile
+++ b/testsuite/tests/ghc-api/annotations/Makefile
@@ -37,6 +37,13 @@ listcomps:
 	'$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc listcomps
 	./listcomps "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
 
+t10358:
+	rm -f t10358.o t10358.hi
+	'$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc t10358
+	./t10358 "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
+
+.PHONY: t10358
+
 t10255:
 	rm -f t10255.o t10255.hi
 	'$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc t10255
diff --git a/testsuite/tests/ghc-api/annotations/T10358.stdout b/testsuite/tests/ghc-api/annotations/T10358.stdout
new file mode 100644
index 0000000..02dcb7a
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/T10358.stdout
@@ -0,0 +1,58 @@
+---Problems---------------------
+[
+(AK <no location info> AnnEofPos = [Test10358.hs:9:1])
+]
+
+---Problems'--------------------
+[(AnnEofPos, Test10358.hs:9:1)]
+--------------------------------
+[
+(AK Test10358.hs:1:1 AnnModule = [Test10358.hs:2:1-6])
+
+(AK Test10358.hs:1:1 AnnWhere = [Test10358.hs:2:18-22])
+
+(AK Test10358.hs:(4,1)-(8,6) AnnEqual = [Test10358.hs:4:13])
+
+(AK Test10358.hs:(4,1)-(8,6) AnnFunId = [Test10358.hs:4:1-7])
+
+(AK Test10358.hs:(4,1)-(8,6) AnnSemi = [Test10358.hs:9:1])
+
+(AK Test10358.hs:(5,3)-(8,6) AnnIn = [Test10358.hs:8:3-4])
+
+(AK Test10358.hs:(5,3)-(8,6) AnnLet = [Test10358.hs:5:3-5])
+
+(AK Test10358.hs:5:7-10 AnnBang = [Test10358.hs:5:7])
+
+(AK Test10358.hs:5:7-16 AnnEqual = [Test10358.hs:5:12])
+
+(AK Test10358.hs:5:7-16 AnnSemi = [Test10358.hs:5:17])
+
+(AK Test10358.hs:5:14-16 AnnVal = [Test10358.hs:5:15])
+
+(AK Test10358.hs:5:19-22 AnnBang = [Test10358.hs:5:19])
+
+(AK Test10358.hs:5:19-32 AnnEqual = [Test10358.hs:5:24])
+
+(AK Test10358.hs:5:19-32 AnnSemi = [Test10358.hs:6:7])
+
+(AK Test10358.hs:5:26-32 AnnVal = [Test10358.hs:5:29])
+
+(AK Test10358.hs:6:7-16 AnnEqual = [Test10358.hs:6:10])
+
+(AK Test10358.hs:6:7-16 AnnFunId = [Test10358.hs:6:7-8])
+
+(AK Test10358.hs:6:7-16 AnnSemi = [Test10358.hs:7:7])
+
+(AK Test10358.hs:6:12-14 AnnVal = [Test10358.hs:6:13])
+
+(AK Test10358.hs:6:12-16 AnnVal = [Test10358.hs:6:15])
+
+(AK Test10358.hs:7:7-17 AnnEqual = [Test10358.hs:7:10])
+
+(AK Test10358.hs:7:7-17 AnnFunId = [Test10358.hs:7:7-8])
+
+(AK Test10358.hs:7:12-17 AnnVal = [Test10358.hs:7:14])
+
+(AK <no location info> AnnEofPos = [Test10358.hs:9:1])
+]
+
diff --git a/testsuite/tests/ghc-api/annotations/Test10358.hs b/testsuite/tests/ghc-api/annotations/Test10358.hs
new file mode 100644
index 0000000..9badab2
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/Test10358.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE BangPatterns #-}
+module Test10358 where
+
+mtGamma a b =
+  let !x_2 = x*x; !x_4 = x_2*x_2
+      v3 = v*v*v
+      dv = d * v3
+  in 5
diff --git a/testsuite/tests/ghc-api/annotations/all.T b/testsuite/tests/ghc-api/annotations/all.T
index 5614127..b60f0bc 100644
--- a/testsuite/tests/ghc-api/annotations/all.T
+++ b/testsuite/tests/ghc-api/annotations/all.T
@@ -12,3 +12,4 @@ test('T10307',      normal, run_command, ['$MAKE -s --no-print-directory t10307'
 test('T10309',      normal, run_command, ['$MAKE -s --no-print-directory t10309'])
 test('boolFormula', normal, run_command, ['$MAKE -s --no-print-directory boolFormula'])
 test('T10357',      normal, run_command, ['$MAKE -s --no-print-directory t10357'])
+test('T10358',      normal, run_command, ['$MAKE -s --no-print-directory t10358'])
diff --git a/testsuite/tests/ghc-api/annotations/t10357.hs b/testsuite/tests/ghc-api/annotations/t10358.hs
similarity index 98%
copy from testsuite/tests/ghc-api/annotations/t10357.hs
copy to testsuite/tests/ghc-api/annotations/t10358.hs
index 93a1f70..82994cc 100644
--- a/testsuite/tests/ghc-api/annotations/t10357.hs
+++ b/testsuite/tests/ghc-api/annotations/t10358.hs
@@ -24,7 +24,7 @@ import Data.Dynamic ( fromDynamic,Dynamic )
 main::IO()
 main = do
         [libdir] <- getArgs
-        testOneFile libdir "Test10357"
+        testOneFile libdir "Test10358"
 
 testOneFile libdir fileName = do
        ((anns,cs),p) <- runGhc (Just libdir) $ do



More information about the ghc-commits mailing list