[Git][ghc/ghc][master] EPA: Provide correct annotation span for ImportDecl

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Aug 1 18:48:30 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00
EPA: Provide correct annotation span for ImportDecl

Use the whole declaration, rather than just the span of the 'import'
keyword.

Metric Decrease:
   T9961
   T5205
Metric Increase:
  T13035

- - - - -


6 changed files:

- compiler/GHC/Parser.y
- testsuite/tests/module/mod185.stderr
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/DumpSemis.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr


Changes:

=====================================
compiler/GHC/Parser.y
=====================================
@@ -1116,8 +1116,9 @@ importdecl :: { LImportDecl GhcPs }
                              , importDeclAnnPackage   = fst $5
                              , importDeclAnnAs        = fst $8
                              }
-                  ; fmap reLocA $ acs (\cs -> L (comb5 $1 $6 $7 (snd $8) $9) $
-                      ImportDecl { ideclExt = XImportDeclPass (EpAnn (glR $1) anns cs) (snd $ fst $2) False
+                  ; let loc = (comb5 $1 $6 $7 (snd $8) $9);
+                  ; fmap reLocA $ acs (\cs -> L loc $
+                      ImportDecl { ideclExt = XImportDeclPass (EpAnn (spanAsAnchor loc) anns cs) (snd $ fst $2) False
                                   , ideclName = $6, ideclPkgQual = snd $5
                                   , ideclSource = snd $2, ideclSafe = snd $3
                                   , ideclQualified = snd $ importDeclQualifiedStyle mPreQual mPostQual


=====================================
testsuite/tests/module/mod185.stderr
=====================================
@@ -31,7 +31,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { mod185.hs:3:1-6 }
+        { mod185.hs:3:1-24 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { mod185.hs:3:1-6 })


=====================================
testsuite/tests/parser/should_compile/DumpParsedAst.stderr
=====================================
@@ -35,7 +35,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { DumpParsedAst.hs:5:1-6 }
+        { DumpParsedAst.hs:5:1-16 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { DumpParsedAst.hs:5:1-6 })


=====================================
testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
=====================================
@@ -1466,7 +1466,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { DumpRenamedAst.hs:5:1-6 }
+        { DumpRenamedAst.hs:5:1-16 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { DumpRenamedAst.hs:5:1-6 })
@@ -1494,7 +1494,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { DumpRenamedAst.hs:7:1-6 }
+        { DumpRenamedAst.hs:7:1-23 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { DumpRenamedAst.hs:7:1-6 })


=====================================
testsuite/tests/parser/should_compile/DumpSemis.stderr
=====================================
@@ -58,7 +58,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { DumpSemis.hs:5:1-6 }
+        { DumpSemis.hs:5:1-19 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { DumpSemis.hs:5:1-6 })
@@ -116,7 +116,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { DumpSemis.hs:7:1-6 }
+        { DumpSemis.hs:7:1-16 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { DumpSemis.hs:7:1-6 })


=====================================
testsuite/tests/parser/should_compile/KindSigs.stderr
=====================================
@@ -35,7 +35,7 @@
      (XImportDeclPass
       (EpAnn
        (Anchor
-        { KindSigs.hs:8:1-6 }
+        { KindSigs.hs:8:1-16 }
         (UnchangedAnchor))
        (EpAnnImportDecl
         (EpaSpan { KindSigs.hs:8:1-6 })



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/465a9a0bb2ecc7b1ec19832949d069b9d2598489

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/465a9a0bb2ecc7b1ec19832949d069b9d2598489
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230801/6db727ff/attachment-0001.html>


More information about the ghc-commits mailing list