[Git][ghc/ghc][wip/int-index/tok-where] fixup! WIP: HsModuleHeaderTokens

Vladislav Zavialov (@int-index) gitlab at gitlab.haskell.org
Fri Jan 6 09:11:03 UTC 2023



Vladislav Zavialov pushed to branch wip/int-index/tok-where at Glasgow Haskell Compiler / GHC


Commits:
99d695c7 by Andrei Borzenkov at 2023-01-04T17:02:36+04:00
fixup! WIP: HsModuleHeaderTokens

Fix tests passing for `WIP: HsModuleHeaderTokens`

- - - - -


17 changed files:

- testsuite/tests/ghc-api/exactprint/Test20239.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
- testsuite/tests/module/mod185.stderr
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
- testsuite/tests/parser/should_compile/DumpSemis.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr
- testsuite/tests/parser/should_compile/T15323.stderr
- testsuite/tests/parser/should_compile/T20452.stderr
- testsuite/tests/parser/should_compile/T20718.stderr
- testsuite/tests/parser/should_compile/T20718b.stderr
- testsuite/tests/parser/should_compile/T20846.stderr
- testsuite/tests/printer/T18791.stderr
- testsuite/tests/printer/Test20297.stdout
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Transform.hs


Changes:

=====================================
testsuite/tests/ghc-api/exactprint/Test20239.stderr
=====================================
@@ -38,6 +38,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { Test20239.hs:1:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { Test20239.hs:1:18-22 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { Test20239.hs:1:8-16 })


=====================================
testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T17544.hs:3:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T17544.hs:3:15-19 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:3:8-13 })


=====================================
testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
=====================================
@@ -43,6 +43,15 @@
           " Bad comment for the module"))
         []))
       []))))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T17544_kw.hs:11:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T17544_kw.hs:13:13-17 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T17544_kw.hs:13:3-11 })
@@ -371,5 +380,3 @@
                " Bad comment for clsmethod"))
              []))
            []))))])))]))
-
-


=====================================
testsuite/tests/module/mod185.stderr
=====================================
@@ -30,6 +30,7 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsNoModTk)
   (Nothing)
   (Nothing)
   [(L


=====================================
testsuite/tests/parser/should_compile/DumpParsedAst.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { DumpParsedAst.hs:5:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { DumpParsedAst.hs:5:22-26 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:5:8-20 })
@@ -1537,5 +1546,3 @@
                     {FastString: "hello"})))))))]
             (EmptyLocalBinds
              (NoExtField)))))])))))]))
-
-


=====================================
testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
=====================================
@@ -47,6 +47,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { DumpParsedAstComments.hs:5:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { DumpParsedAstComments.hs:5:30-34 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:5:8-28 })


=====================================
testsuite/tests/parser/should_compile/DumpSemis.stderr
=====================================
@@ -42,6 +42,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { DumpSemis.hs:1:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { DumpSemis.hs:1:18-22 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:1:8-16 })
@@ -2121,5 +2130,3 @@
                         (NoExtField)))))]))))))]
             (EmptyLocalBinds
              (NoExtField)))))])))))]))
-
-


=====================================
testsuite/tests/parser/should_compile/KindSigs.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { KindSigs.hs:6:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { KindSigs.hs:6:17-21 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { KindSigs.hs:6:8-15 })


=====================================
testsuite/tests/parser/should_compile/T15323.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T15323.hs:3:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T15323.hs:3:15-19 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T15323.hs:3:8-13 })
@@ -233,5 +242,3 @@
                  {OccName: v}))))))
            (Nothing)))])
        []))))]))
-
-


=====================================
testsuite/tests/parser/should_compile/T20452.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T20452.hs:3:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T20452.hs:3:15-19 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T20452.hs:3:8-13 })
@@ -627,5 +636,3 @@
       []
       []
       [])))]))
-
-


=====================================
testsuite/tests/parser/should_compile/T20718.stderr
=====================================
@@ -62,6 +62,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T20718.hs:3:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T20718.hs:3:15-19 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:3:8-13 })


=====================================
testsuite/tests/parser/should_compile/T20718b.stderr
=====================================
@@ -62,6 +62,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T20718b.hs:4:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T20718b.hs:4:16-20 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T20718b.hs:4:8-14 })
@@ -69,5 +78,3 @@
   (Nothing)
   []
   []))
-
-


=====================================
testsuite/tests/parser/should_compile/T20846.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T20846.hs:1:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T20846.hs:1:15-19 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T20846.hs:1:8-13 })


=====================================
testsuite/tests/printer/T18791.stderr
=====================================
@@ -31,6 +31,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { T18791.hs:2:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { T18791.hs:2:15-19 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { T18791.hs:2:8-13 })
@@ -143,5 +152,3 @@
                {OccName: T}))))
            (Nothing)))])
        []))))]))
-
-


=====================================
testsuite/tests/printer/Test20297.stdout
=====================================
@@ -38,6 +38,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { Test20297.hs:2:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { Test20297.hs:2:18-22 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { Test20297.hs:2:8-16 })
@@ -385,6 +394,15 @@
     (1))
    (Nothing)
    (Nothing))
+  (HsModTk
+   (L
+    (TokenLoc
+     (EpaSpan { Test20297.ppr.hs:2:1-6 }))
+    (HsTok))
+   (L
+    (TokenLoc
+     (EpaSpan { Test20297.ppr.hs:2:18-22 }))
+    (HsTok)))
   (Just
    (L
     (SrcSpanAnn (EpAnnNotUsed) { Test20297.ppr.hs:2:8-16 })
@@ -669,4 +687,3 @@
                         (EmptyLocalBinds
                          (NoExtField)))))]))))]}
               [])))))])))))]))
-


=====================================
utils/check-exact/ExactPrint.hs
=====================================
@@ -1367,7 +1367,7 @@ instance ExactPrint (HsModule GhcPs) where
                    `debug` ("setAnnotationAnchor hsmod called" ++ showAst (anc,cs))
 
   exact hsmod@(HsModule {hsmodExt = XModulePs { hsmodAnn = EpAnnNotUsed }}) = withPpr hsmod >> return hsmod
-  exact (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports imports decls) = do
+  exact (HsModule (XModulePs an lo mdeprec mbDoc) headertoks mmn mexports imports decls) = do
 
     mbDoc' <- markAnnotated mbDoc
 
@@ -1398,7 +1398,7 @@ instance ExactPrint (HsModule GhcPs) where
     let anf = an0 { anns = (anns an0) { am_decls = am_decls' }}
     debugM $ "HsModule, anf=" ++ showAst anf
 
-    return (HsModule (XModulePs anf lo mdeprec' mbDoc') mmn' mexports' imports' decls')
+    return (HsModule (XModulePs anf lo mdeprec' mbDoc') headertoks mmn' mexports' imports' decls')
 
 -- ---------------------------------------------------------------------
 


=====================================
utils/check-exact/Transform.hs
=====================================
@@ -753,7 +753,7 @@ balanceSameLineComments (L la (Match anm mctxt pats (GRHSs x grhss lb))) = do
 -- ---------------------------------------------------------------------
 
 anchorEof :: ParsedSource -> ParsedSource
-anchorEof (L l m@(HsModule (XModulePs an _lo _ _) _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } })
+anchorEof (L l m@(HsModule (XModulePs an _lo _ _) _ht _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } })
   where
     an' = addCommentOrigDeltasAnn an
 
@@ -893,12 +893,12 @@ class (Data t) => HasDecls t where
 -- ---------------------------------------------------------------------
 
 instance HasDecls ParsedSource where
-  hsDecls (L _ (HsModule (XModulePs _ _lo _ _) _mn _exps _imps decls)) = return decls
-  replaceDecls (L l (HsModule (XModulePs a lo deps haddocks) mname exps imps _decls)) decls
+  hsDecls (L _ (HsModule (XModulePs _ _lo _ _) _ht _mn _exps _imps decls)) = return decls
+  replaceDecls (L l (HsModule (XModulePs a lo deps haddocks) headertoks mname exps imps _decls)) decls
     = do
         logTr "replaceDecls LHsModule"
         -- modifyAnnsT (captureOrder m decls)
-        return (L l (HsModule (XModulePs a lo deps haddocks) mname exps imps decls))
+        return (L l (HsModule (XModulePs a lo deps haddocks) headertoks mname exps imps decls))
 
 -- ---------------------------------------------------------------------
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/99d695c7b4af6e6df4bfbc6f9316e7d0cbf28e98

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/99d695c7b4af6e6df4bfbc6f9316e7d0cbf28e98
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/20230106/438a16a2/attachment-0001.html>


More information about the ghc-commits mailing list