[commit: ghc] ghc-7.10: ApiAnnotations : PatBind gives wrong SrcSpan for the pattern. (300a10c)

git at git.haskell.org git at git.haskell.org
Mon May 11 22:30:22 UTC 2015


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

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/300a10c627887ed39788cc73de40fb1844ed1474/ghc

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

commit 300a10c627887ed39788cc73de40fb1844ed1474
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date:   Mon May 11 17:57:05 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
    
    Reviewed By: austin
    
    Subscribers: bgamari, thomie, mpickering
    
    Differential Revision: https://phabricator.haskell.org/D873
    
    GHC Trac Issues: #10358
    
    (cherry picked from commit ecc3d6be218b1c7a36ee3f2f36c4f3ac4f45c34f)


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

300a10c627887ed39788cc73de40fb1844ed1474
 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.stderr  | 12 +++++
 testsuite/tests/ghc-api/annotations/T10358.stdout  | 58 ++++++++++++++++++++++
 testsuite/tests/ghc-api/annotations/Test10358.hs   |  8 +++
 testsuite/tests/ghc-api/annotations/all.T          |  1 +
 .../tests/ghc-api/annotations/boolFormula.stderr   | 17 -------
 .../ghc-api/annotations/{t10357.hs => t10358.hs}   |  2 +-
 9 files changed, 90 insertions(+), 20 deletions(-)

diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index be193b3..623bcaa 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -1853,10 +1853,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.stderr b/testsuite/tests/ghc-api/annotations/T10358.stderr
new file mode 100644
index 0000000..96daaad
--- /dev/null
+++ b/testsuite/tests/ghc-api/annotations/T10358.stderr
@@ -0,0 +1,12 @@
+
+Test10358.hs:5:14: error: Not in scope: ‘x’
+
+Test10358.hs:5:16: error: Not in scope: ‘x’
+
+Test10358.hs:6:12: error: Not in scope: ‘v’
+
+Test10358.hs:6:14: error: Not in scope: ‘v’
+
+Test10358.hs:6:16: error: Not in scope: ‘v’
+
+Test10358.hs:7:12: error: Not in scope: ‘d’
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/boolFormula.stderr b/testsuite/tests/ghc-api/annotations/boolFormula.stderr
deleted file mode 100644
index 65cbf26..0000000
--- a/testsuite/tests/ghc-api/annotations/boolFormula.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-
-TestBoolFormula.hs:3:1: Warning:
-    The MINIMAL pragma does not require:
-      ‘aOp’, ‘bOp’, ‘cOp’, ‘dOp’, ‘eOp’, and ‘fOp’
-    but there is no default implementation.
-    In the class declaration for ‘ManyOps’
-
-TestBoolFormula.hs:15:1: Warning:
-    The MINIMAL pragma does not require:
-      ‘baq’, ‘baz’, and ‘quux’
-    but there is no default implementation.
-    In the class declaration for ‘Foo’
-
-TestBoolFormula.hs:23:10: Warning:
-    No explicit implementation for
-      either (‘foo’ and ‘baq’) or ‘foo’
-    In the instance declaration for ‘Foo Int’
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