Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
e358619f
by Alan Zimmerman at 2026-10-01T06:59:01-04:00
24 changed files:
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- testsuite/tests/ghc-api/exactprint/T22919.stderr
- testsuite/tests/ghc-api/exactprint/Test20239.stderr
- testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/T24221.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/parser/should_compile/T23315/T23315.stderr
- testsuite/tests/printer/AnnotationNoListTuplePuns.stdout
- testsuite/tests/printer/T18791.stderr
- testsuite/tests/printer/Test20297.stdout
- testsuite/tests/printer/Test24533.stdout
Changes:
| ... | ... | @@ -945,13 +945,13 @@ body :: { ([TrailingAnn] |
| 945 | 945 | ,([LImportDecl GhcPs], [LHsDecl GhcPs])
|
| 946 | 946 | ,EpLayout) }
|
| 947 | 947 | : '{' top '}' { (fst $2, snd $2, epExplicitBraces $1 $3) }
|
| 948 | - | vocurly top close { (fst $2, snd $2, EpVirtualBraces (getVOCURLY $1)) }
|
|
| 948 | + | vocurly top close { (fst $2, snd $2, EpVirtualBraces (glR $1)) }
|
|
| 949 | 949 | |
| 950 | 950 | body2 :: { ([TrailingAnn]
|
| 951 | 951 | ,([LImportDecl GhcPs], [LHsDecl GhcPs])
|
| 952 | 952 | ,EpLayout) }
|
| 953 | 953 | : '{' top '}' { (fst $2, snd $2, epExplicitBraces $1 $3) }
|
| 954 | - | missing_module_keyword top close { ([], snd $2, EpVirtualBraces leftmostColumn) }
|
|
| 954 | + | missing_module_keyword top close { ([], snd $2, EpVirtualBraces (EpaDelta noSrcSpan (SameLine 0) [])) }
|
|
| 955 | 955 | |
| 956 | 956 | |
| 957 | 957 | top :: { ([TrailingAnn]
|
| ... | ... | @@ -1855,7 +1855,7 @@ decllist_cls |
| 1855 | 1855 | : '{' decls_cls '}' { sLL $1 $> ((epTok $1, fst $ unLoc $2, epTok $3)
|
| 1856 | 1856 | ,snd $ unLoc $2, epExplicitBraces $1 $3) }
|
| 1857 | 1857 | | vocurly decls_cls close { let { L l (anns, decls) = $2 }
|
| 1858 | - in L l ((noEpTok, anns, noEpTok), decls, EpVirtualBraces (getVOCURLY $1)) }
|
|
| 1858 | + in L l ((noEpTok, anns, noEpTok), decls, EpVirtualBraces (glR $1)) }
|
|
| 1859 | 1859 | |
| 1860 | 1860 | -- Class body
|
| 1861 | 1861 | --
|
| ... | ... | @@ -4305,7 +4305,6 @@ getINLINE (L _ (ITinline_prag _ inl conl)) = (inl,conl) |
| 4305 | 4305 | getSPEC_INLINE (L _ (ITspec_inline_prag src True)) = (Inline,FunLike)
|
| 4306 | 4306 | getSPEC_INLINE (L _ (ITspec_inline_prag src False)) = (NoInline,FunLike)
|
| 4307 | 4307 | getCOMPLETE_PRAGs (L _ (ITcomplete_prag x)) = x
|
| 4308 | -getVOCURLY (L (RealSrcSpan l _) ITvocurly) = srcSpanStartCol l
|
|
| 4309 | 4308 | |
| 4310 | 4309 | getINTEGERs (L _ (ITinteger (IL src _ _))) = src
|
| 4311 | 4310 | getCHARs (L _ (ITchar src _)) = src
|
| ... | ... | @@ -5,7 +5,7 @@ module GHC.Parser.Annotation ( |
| 5 | 5 | getEpTokenBufSpan,
|
| 6 | 6 | getEpTokenLoc, getEpUniTokenLoc,
|
| 7 | 7 | TokDcolon, TokDarrow, TokRarrow, TokForall, TokStar,
|
| 8 | - EpLayout(..),
|
|
| 8 | + EpLayout(..), getEpaLocationCol,
|
|
| 9 | 9 | EpaComment(..), EpaCommentTok(..),
|
| 10 | 10 | IsUnicodeSyntax(..),
|
| 11 | 11 | HasE(..),
|
| ... | ... | @@ -282,7 +282,9 @@ data EpLayout = |
| 282 | 282 | -- bar :: a
|
| 283 | 283 | -- @
|
| 284 | 284 | EpVirtualBraces
|
| 285 | - !Int -- ^ Layout column (indentation level, begins at 1)
|
|
| 285 | + !EpaLocation -- ^ Layout column (indentation level, begins at 1)
|
|
| 286 | + -- We keep this as an 'EpaLocation' so exact printing
|
|
| 287 | + -- can use it too.
|
|
| 286 | 288 | |
|
| 287 | 289 | -- | Empty or compiler-generated blocks do not have layout information
|
| 288 | 290 | -- associated with them.
|
| ... | ... | @@ -290,6 +292,14 @@ data EpLayout = |
| 290 | 292 | |
| 291 | 293 | deriving instance Data EpLayout
|
| 292 | 294 | |
| 295 | +-- | Used in 'GHC.Parser.Haddock' to get layout column. It assumes
|
|
| 296 | +-- | there is a RealSrcSpan in it, falling back to zero otherwise
|
|
| 297 | +getEpaLocationCol :: EpaLocation -> Int
|
|
| 298 | +getEpaLocationCol loc
|
|
| 299 | + = case loc of
|
|
| 300 | + EpaSpan (RealSrcSpan l _) -> srcSpanStartCol l
|
|
| 301 | + _ -> leftmostColumn -- should never happen in Parser output
|
|
| 302 | + |
|
| 293 | 303 | -- ---------------------------------------------------------------------
|
| 294 | 304 | |
| 295 | 305 | data EpaComment =
|
| ... | ... | @@ -392,8 +392,9 @@ addHaddockInterleaveItems layout get_doc_item = go |
| 392 | 392 | with_layout = case layout of
|
| 393 | 393 | EpNoLayout -> id
|
| 394 | 394 | EpExplicitBraces{} -> id
|
| 395 | - EpVirtualBraces n ->
|
|
| 396 | - let loc_range = mempty { loc_range_col = ColumnFrom (n+1) }
|
|
| 395 | + EpVirtualBraces n' ->
|
|
| 396 | + let n = getEpaLocationCol n'
|
|
| 397 | + loc_range = mempty { loc_range_col = ColumnFrom (n+1) }
|
|
| 397 | 398 | in hoistHdkA (inLocRange loc_range)
|
| 398 | 399 | |
| 399 | 400 | instance HasHaddock (LocatedA (HsDecl GhcPs)) where
|
| ... | ... | @@ -1304,7 +1305,7 @@ mkDocDecl layout (L l_comment hdk_comment) |
| 1304 | 1305 | indent_mismatch = case layout of
|
| 1305 | 1306 | EpNoLayout -> False
|
| 1306 | 1307 | EpExplicitBraces{} -> False
|
| 1307 | - EpVirtualBraces n -> n /= srcSpanStartCol (psRealSpan l_comment)
|
|
| 1308 | + EpVirtualBraces n -> getEpaLocationCol n /= srcSpanStartCol (psRealSpan l_comment)
|
|
| 1308 | 1309 | |
| 1309 | 1310 | mkDocIE :: PsLocated HdkComment -> Maybe (LIE GhcPs)
|
| 1310 | 1311 | mkDocIE (L l_comment hdk_comment) =
|
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | { T22919.hs:1:8-13 }))]
|
| 35 | 35 | []))
|
| 36 | 36 | (EpVirtualBraces
|
| 37 | - (1))
|
|
| 37 | + (EpaSpan { T22919.hs:2:1 }))
|
|
| 38 | 38 | (Nothing)
|
| 39 | 39 | (Nothing))
|
| 40 | 40 | (Just
|
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | "-- ^ Run any arbitrary IO code")
|
| 35 | 35 | { Test20239.hs:7:86 }))]))
|
| 36 | 36 | (EpVirtualBraces
|
| 37 | - (1))
|
|
| 37 | + (EpaSpan { Test20239.hs:5:1 }))
|
|
| 38 | 38 | (Nothing)
|
| 39 | 39 | (Nothing))
|
| 40 | 40 | (Just
|
| ... | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | "-- Trailing comment, should be in HsModule extension point")
|
| 41 | 41 | { ZeroWidthSemi.hs:6:5 }))]))
|
| 42 | 42 | (EpVirtualBraces
|
| 43 | - (1))
|
|
| 43 | + (EpaSpan { ZeroWidthSemi.hs:6:1 }))
|
|
| 44 | 44 | (Nothing)
|
| 45 | 45 | (Nothing))
|
| 46 | 46 | (Just
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T17544.hs:5:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -64,7 +64,7 @@ |
| 64 | 64 | (EpTok (EpaSpan { <no location info> }))
|
| 65 | 65 | [])
|
| 66 | 66 | (EpVirtualBraces
|
| 67 | - (3)))
|
|
| 67 | + (EpaSpan { T17544.hs:6:3 })))
|
|
| 68 | 68 | []
|
| 69 | 69 | (Nothing)
|
| 70 | 70 | (L
|
| ... | ... | @@ -243,7 +243,7 @@ |
| 243 | 243 | (EpTok (EpaSpan { <no location info> }))
|
| 244 | 244 | [])
|
| 245 | 245 | (EpVirtualBraces
|
| 246 | - (3)))
|
|
| 246 | + (EpaSpan { T17544.hs:10:3 })))
|
|
| 247 | 247 | []
|
| 248 | 248 | (Nothing)
|
| 249 | 249 | (L
|
| ... | ... | @@ -423,7 +423,7 @@ |
| 423 | 423 | (EpTok (EpaSpan { <no location info> }))
|
| 424 | 424 | [])
|
| 425 | 425 | (EpVirtualBraces
|
| 426 | - (3)))
|
|
| 426 | + (EpaSpan { T17544.hs:14:3 })))
|
|
| 427 | 427 | []
|
| 428 | 428 | (Nothing)
|
| 429 | 429 | (L
|
| ... | ... | @@ -603,7 +603,7 @@ |
| 603 | 603 | (EpTok (EpaSpan { <no location info> }))
|
| 604 | 604 | [])
|
| 605 | 605 | (EpVirtualBraces
|
| 606 | - (3)))
|
|
| 606 | + (EpaSpan { T17544.hs:18:3 })))
|
|
| 607 | 607 | []
|
| 608 | 608 | (Nothing)
|
| 609 | 609 | (L
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T17544_kw.hs:13:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -412,7 +412,7 @@ |
| 412 | 412 | (EpTok (EpaSpan { <no location info> }))
|
| 413 | 413 | [])
|
| 414 | 414 | (EpVirtualBraces
|
| 415 | - (5)))
|
|
| 415 | + (EpaSpan { T17544_kw.hs:22:5 })))
|
|
| 416 | 416 | []
|
| 417 | 417 | (Nothing)
|
| 418 | 418 | (L
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T24221.hs:3:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaDelta { <no location info> } (SameLine 0) []))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Nothing)
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { DumpParsedAst.hs:5:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 | { DumpParsedAstComments.hs:1:1-28 }))]
|
| 42 | 42 | []))
|
| 43 | 43 | (EpVirtualBraces
|
| 44 | - (1))
|
|
| 44 | + (EpaSpan { DumpParsedAstComments.hs:9:1 }))
|
|
| 45 | 45 | (Nothing)
|
| 46 | 46 | (Nothing))
|
| 47 | 47 | (Just
|
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | []
|
| 46 | 46 | []))
|
| 47 | 47 | (EpVirtualBraces
|
| 48 | - (1))
|
|
| 48 | + (EpaSpan { DumpSemis.hs:4:1 }))
|
|
| 49 | 49 | (Nothing)
|
| 50 | 50 | (Nothing))
|
| 51 | 51 | (Just
|
| ... | ... | @@ -1336,7 +1336,7 @@ |
| 1336 | 1336 | (EpTok (EpaSpan { <no location info> }))
|
| 1337 | 1337 | [])
|
| 1338 | 1338 | (EpVirtualBraces
|
| 1339 | - (3)))
|
|
| 1339 | + (EpaSpan { DumpSemis.hs:29:3 })))
|
|
| 1340 | 1340 | []
|
| 1341 | 1341 | (Nothing)
|
| 1342 | 1342 | (L
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { KindSigs.hs:8:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T15323.hs:5:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T20452.hs:5:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | "-- end 2")
|
| 69 | 69 | { T20718.hs:10:1-8 }))]))
|
| 70 | 70 | (EpVirtualBraces
|
| 71 | - (1))
|
|
| 71 | + (EpaSpan { T20718.hs:8:1 }))
|
|
| 72 | 72 | (Nothing)
|
| 73 | 73 | (Nothing))
|
| 74 | 74 | (Just
|
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | { T20718b.hs:6:1-21 }))]
|
| 56 | 56 | []))
|
| 57 | 57 | (EpVirtualBraces
|
| 58 | - (1))
|
|
| 58 | + (EpaSpan { T20718b.hs:8:1 }))
|
|
| 59 | 59 | (Nothing)
|
| 60 | 60 | (Nothing))
|
| 61 | 61 | (Just
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T20846.hs:3:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | (EpaComments
|
| 25 | 25 | []))
|
| 26 | 26 | (EpVirtualBraces
|
| 27 | - (1))
|
|
| 27 | + (EpaSpan { T23315.hsig:3:1 }))
|
|
| 28 | 28 | (Nothing)
|
| 29 | 29 | (Nothing))
|
| 30 | 30 | (Just
|
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | "-- comment post B")
|
| 48 | 48 | { AnnotationNoListTuplePuns.hs:17:3 }))]))
|
| 49 | 49 | (EpVirtualBraces
|
| 50 | - (1))
|
|
| 50 | + (EpaSpan { AnnotationNoListTuplePuns.hs:5:1 }))
|
|
| 51 | 51 | (Nothing)
|
| 52 | 52 | (Nothing))
|
| 53 | 53 | (Just
|
| ... | ... | @@ -244,7 +244,7 @@ |
| 244 | 244 | { AnnotationNoListTuplePuns.ppr.hs:1:1-32 }))]
|
| 245 | 245 | []))
|
| 246 | 246 | (EpVirtualBraces
|
| 247 | - (1))
|
|
| 247 | + (EpaSpan { AnnotationNoListTuplePuns.ppr.hs:4:1 }))
|
|
| 248 | 248 | (Nothing)
|
| 249 | 249 | (Nothing))
|
| 250 | 250 | (Just
|
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | []
|
| 29 | 29 | []))
|
| 30 | 30 | (EpVirtualBraces
|
| 31 | - (1))
|
|
| 31 | + (EpaSpan { T18791.hs:4:1 }))
|
|
| 32 | 32 | (Nothing)
|
| 33 | 33 | (Nothing))
|
| 34 | 34 | (Just
|
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | { Test20297.hs:1:1 }))]
|
| 35 | 35 | []))
|
| 36 | 36 | (EpVirtualBraces
|
| 37 | - (1))
|
|
| 37 | + (EpaSpan { Test20297.hs:5:1 }))
|
|
| 38 | 38 | (Nothing)
|
| 39 | 39 | (Nothing))
|
| 40 | 40 | (Just
|
| ... | ... | @@ -476,7 +476,7 @@ |
| 476 | 476 | { Test20297.ppr.hs:1:1 }))]
|
| 477 | 477 | []))
|
| 478 | 478 | (EpVirtualBraces
|
| 479 | - (1))
|
|
| 479 | + (EpaSpan { Test20297.ppr.hs:3:1 }))
|
|
| 480 | 480 | (Nothing)
|
| 481 | 481 | (Nothing))
|
| 482 | 482 | (Just
|
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | { Test24533.hs:1:1 }))]
|
| 35 | 35 | []))
|
| 36 | 36 | (EpVirtualBraces
|
| 37 | - (1))
|
|
| 37 | + (EpaSpan { Test24533.hs:4:1 }))
|
|
| 38 | 38 | (Nothing)
|
| 39 | 39 | (Nothing))
|
| 40 | 40 | (Just
|
| ... | ... | @@ -694,7 +694,7 @@ |
| 694 | 694 | { Test24533.ppr.hs:1:1 }))]
|
| 695 | 695 | []))
|
| 696 | 696 | (EpVirtualBraces
|
| 697 | - (1))
|
|
| 697 | + (EpaSpan { Test24533.ppr.hs:3:1 }))
|
|
| 698 | 698 | (Nothing)
|
| 699 | 699 | (Nothing))
|
| 700 | 700 | (Just
|