Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
130286e3
by Alan Zimmerman at 2026-09-11T08:34:08-04:00
8 changed files:
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/PostProcess.hs
- testsuite/tests/ghc-api/T25121_status.stdout
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Utils.hs
Changes:
| ... | ... | @@ -294,7 +294,7 @@ type instance XDo GhcPs = (AnnList, EpaLocation) |
| 294 | 294 | type instance XDo GhcRn = NoExtField
|
| 295 | 295 | type instance XDo GhcTc = Type
|
| 296 | 296 | |
| 297 | -type instance XExplicitList GhcPs = AnnList
|
|
| 297 | +type instance XExplicitList GhcPs = (EpToken "[", EpToken "]")
|
|
| 298 | 298 | type instance XExplicitList GhcRn = NoExtField
|
| 299 | 299 | type instance XExplicitList GhcTc = Type
|
| 300 | 300 | -- GhcPs: ExplicitList includes all source-level
|
| ... | ... | @@ -1440,7 +1440,7 @@ type instance XCmdArrApp GhcPs = (IsUnicodeSyntax, EpaLocation) |
| 1440 | 1440 | type instance XCmdArrApp GhcRn = NoExtField
|
| 1441 | 1441 | type instance XCmdArrApp GhcTc = Type
|
| 1442 | 1442 | |
| 1443 | -type instance XCmdArrForm GhcPs = AnnList
|
|
| 1443 | +type instance XCmdArrForm GhcPs = (EpUniToken "(|" "⦇", EpUniToken "|)" "⦈")
|
|
| 1444 | 1444 | -- | fixity (filled in by the renamer), for forms that were converted from
|
| 1445 | 1445 | -- OpApp's by the renamer
|
| 1446 | 1446 | type instance XCmdArrForm GhcRn = Maybe Fixity
|
| ... | ... | @@ -104,7 +104,7 @@ type instance XBangPat GhcPs = EpToken "!" |
| 104 | 104 | type instance XBangPat GhcRn = NoExtField
|
| 105 | 105 | type instance XBangPat GhcTc = NoExtField
|
| 106 | 106 | |
| 107 | -type instance XListPat GhcPs = AnnList
|
|
| 107 | +type instance XListPat GhcPs = (EpToken "[", EpToken "]")
|
|
| 108 | 108 | -- After parsing, ListPat can refer to a built-in Haskell list pattern
|
| 109 | 109 | -- or an overloaded list pattern.
|
| 110 | 110 | type instance XListPat GhcRn = NoExtField
|
| ... | ... | @@ -3282,7 +3282,7 @@ aexp2 :: { ECP } |
| 3282 | 3282 | -- arrow notation extension
|
| 3283 | 3283 | | '(|' aexp cmdargs '|)' {% runPV (unECP $2) >>= \ $2 ->
|
| 3284 | 3284 | fmap ecpFromCmd $
|
| 3285 | - amsA' (sLL $1 $> $ HsCmdArrForm (AnnList (glRM $1) (ListBanana (epUniTok $1) (epUniTok $4)) []) $2 Prefix
|
|
| 3285 | + amsA' (sLL $1 $> $ HsCmdArrForm (epUniTok $1, epUniTok $4) $2 Prefix
|
|
| 3286 | 3286 | (reverse $3)) }
|
| 3287 | 3287 | |
| 3288 | 3288 | projection :: { Located (NonEmpty (LocatedAn NoEpAnns (DotFieldOcc GhcPs))) }
|
| ... | ... | @@ -3414,9 +3414,9 @@ tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn Bool) (LocatedA b)] } |
| 3414 | 3414 | -- Never empty.
|
| 3415 | 3415 | list :: { forall b. DisambECP b => SrcSpan -> (EpaLocation, EpaLocation) -> PV (LocatedA b) }
|
| 3416 | 3416 | : texp { \loc (ao,ac) -> unECP $1 >>= \ $1 ->
|
| 3417 | - mkHsExplicitListPV loc [$1] (AnnList Nothing (ListSquare (EpTok ao) (EpTok ac)) []) }
|
|
| 3417 | + mkHsExplicitListPV loc [$1] (EpTok ao, EpTok ac) }
|
|
| 3418 | 3418 | | lexps { \loc (ao,ac) -> $1 >>= \ $1 ->
|
| 3419 | - mkHsExplicitListPV loc (reverse $1) (AnnList Nothing (ListSquare (EpTok ao) (EpTok ac)) []) }
|
|
| 3419 | + mkHsExplicitListPV loc (reverse $1) (EpTok ao, EpTok ac) }
|
|
| 3420 | 3420 | | texp '..' { \loc (ao,ac) -> unECP $1 >>= \ $1 ->
|
| 3421 | 3421 | amsA' (L loc $ ArithSeq (AnnArithSeq (EpTok ao) Nothing (epTok $2) (EpTok ac)) Nothing (From $1))
|
| 3422 | 3422 | >>= ecpFromExp' }
|
| ... | ... | @@ -519,10 +519,8 @@ data AnnList |
| 519 | 519 | } deriving (Data,Eq)
|
| 520 | 520 | |
| 521 | 521 | data AnnListBrackets
|
| 522 | - = ListParens (EpToken "(") (EpToken ")")
|
|
| 523 | - | ListBraces (EpToken "{") (EpToken "}")
|
|
| 522 | + = ListBraces (EpToken "{") (EpToken "}")
|
|
| 524 | 523 | | ListSquare (EpToken "[") (EpToken "]")
|
| 525 | - | ListBanana (EpUniToken "(|" "⦇") (EpUniToken "|)" "⦈")
|
|
| 526 | 524 | | ListNone
|
| 527 | 525 | deriving (Data,Eq)
|
| 528 | 526 | |
| ... | ... | @@ -1094,10 +1092,8 @@ instance Outputable AnnList where |
| 1094 | 1092 | = text "AnnList" <+> ppr l <+> ppr p <+> ppr s
|
| 1095 | 1093 | |
| 1096 | 1094 | instance Outputable AnnListBrackets where
|
| 1097 | - ppr (ListParens o c) = text "ListParens" <+> ppr o <+> ppr c
|
|
| 1098 | 1095 | ppr (ListBraces o c) = text "ListBraces" <+> ppr o <+> ppr c
|
| 1099 | 1096 | ppr (ListSquare o c) = text "ListSquare" <+> ppr o <+> ppr c
|
| 1100 | - ppr (ListBanana o c) = text "ListBanana" <+> ppr o <+> ppr c
|
|
| 1101 | 1097 | ppr ListNone = text "ListNone"
|
| 1102 | 1098 | |
| 1103 | 1099 | instance Outputable AnnCType where
|
| ... | ... | @@ -1827,7 +1827,7 @@ class (b ~ (Body b) GhcPs, AnnoBody b) => DisambECP b where |
| 1827 | 1827 | mkHsTySigPV
|
| 1828 | 1828 | :: SrcSpanAnnA -> LocatedA b -> LHsType GhcPs -> TokDcolon -> PV (LocatedA b)
|
| 1829 | 1829 | -- | Disambiguate "[a,b,c]" (list syntax)
|
| 1830 | - mkHsExplicitListPV :: SrcSpan -> [LocatedA b] -> AnnList -> PV (LocatedA b)
|
|
| 1830 | + mkHsExplicitListPV :: SrcSpan -> [LocatedA b] -> (EpToken "[", EpToken "]") -> PV (LocatedA b)
|
|
| 1831 | 1831 | -- | Disambiguate "$(...)" and "[quasi|...|]" (TH splices)
|
| 1832 | 1832 | mkHsSplicePV :: Located (HsUntypedSplice GhcPs) -> PV (LocatedA b)
|
| 1833 | 1833 | -- | Disambiguate "f { a = b, ... }" syntax (record construction and record updates)
|
| ... | ... | @@ -15,7 +15,7 @@ X(FunArr) match = NoExtField |
| 15 | 15 | X(ExprWithTySig) match = EpUniToken "::" "\8759"
|
| 16 | 16 | X(UntypedSplice) match = NoExtField
|
| 17 | 17 | X(ExplicitList) mismatch
|
| 18 | - >>> AnnList
|
|
| 18 | + >>> ((EpToken "["),(EpToken "]"))
|
|
| 19 | 19 | <<< ((EpToken "'"),(EpToken "["),(EpToken "]"))
|
| 20 | 20 | X(ExplicitTuple) mismatch
|
| 21 | 21 | >>> AnnParen
|
| ... | ... | @@ -764,18 +764,12 @@ markLensBracketsO' :: (Monad m, Monoid w) |
| 764 | 764 | => a -> Lens a AnnListBrackets -> EP w m a
|
| 765 | 765 | markLensBracketsO' a l =
|
| 766 | 766 | case view l a of
|
| 767 | - ListParens o c -> do
|
|
| 768 | - o' <- markEpToken o
|
|
| 769 | - return (set l (ListParens o' c) a)
|
|
| 770 | 767 | ListBraces o c -> do
|
| 771 | 768 | o' <- markEpToken o
|
| 772 | 769 | return (set l (ListBraces o' c) a)
|
| 773 | 770 | ListSquare o c -> do
|
| 774 | 771 | o' <- markEpToken o
|
| 775 | 772 | return (set l (ListSquare o' c) a)
|
| 776 | - ListBanana o c -> do
|
|
| 777 | - o' <- markEpUniToken o
|
|
| 778 | - return (set l (ListBanana o' c) a)
|
|
| 779 | 773 | ListNone -> return (set l ListNone a)
|
| 780 | 774 | |
| 781 | 775 | markLensBracketsC :: (Monad m, Monoid w)
|
| ... | ... | @@ -786,18 +780,12 @@ markLensBracketsC' :: (Monad m, Monoid w) |
| 786 | 780 | => a -> Lens a AnnListBrackets -> EP w m a
|
| 787 | 781 | markLensBracketsC' a l =
|
| 788 | 782 | case view l a of
|
| 789 | - ListParens o c -> do
|
|
| 790 | - c' <- markEpToken c
|
|
| 791 | - return (set l (ListParens o c') a)
|
|
| 792 | 783 | ListBraces o c -> do
|
| 793 | 784 | c' <- markEpToken c
|
| 794 | 785 | return (set l (ListBraces o c') a)
|
| 795 | 786 | ListSquare o c -> do
|
| 796 | 787 | c' <- markEpToken c
|
| 797 | 788 | return (set l (ListSquare o c') a)
|
| 798 | - ListBanana o c -> do
|
|
| 799 | - c' <- markEpUniToken c
|
|
| 800 | - return (set l (ListBanana o c') a)
|
|
| 801 | 789 | ListNone -> return (set l ListNone a)
|
| 802 | 790 | |
| 803 | 791 | -- -------------------------------------
|
| ... | ... | @@ -2919,13 +2907,13 @@ instance ExactPrint (HsExpr GhcPs) where |
| 2919 | 2907 | (an',l',stmts') <- exactDo (an,l) do_or_list_comp stmts
|
| 2920 | 2908 | return (HsDo (an',l') do_or_list_comp stmts')
|
| 2921 | 2909 | |
| 2922 | - exact (ExplicitList an es) = do
|
|
| 2910 | + exact (ExplicitList (o,c) es) = do
|
|
| 2923 | 2911 | debugM $ "ExplicitList start"
|
| 2924 | - an0 <- markLensBracketsO' an lal_brackets
|
|
| 2912 | + o' <- markEpToken o
|
|
| 2925 | 2913 | es' <- mapM markAnnotated es
|
| 2926 | - an1 <- markLensBracketsC' an0 lal_brackets
|
|
| 2914 | + c' <- markEpToken c
|
|
| 2927 | 2915 | debugM $ "ExplicitList end"
|
| 2928 | - return (ExplicitList an1 es')
|
|
| 2916 | + return (ExplicitList (o',c') es')
|
|
| 2929 | 2917 | exact (RecordCon x con_id binds) = do
|
| 2930 | 2918 | con_id' <- markAnnotated con_id
|
| 2931 | 2919 | binds' <- markAnnotated binds
|
| ... | ... | @@ -3335,8 +3323,8 @@ instance ExactPrint (HsCmd GhcPs) where |
| 3335 | 3323 | arr' <- markAnnotated arr
|
| 3336 | 3324 | return (HsCmdArrApp (isU, l') arr' arg' HsHigherOrderApp False)
|
| 3337 | 3325 | |
| 3338 | - exact (HsCmdArrForm an e fixity cs) = do
|
|
| 3339 | - an0 <- markLensBracketsO' an lal_brackets
|
|
| 3326 | + exact (HsCmdArrForm (o,c) e fixity cs) = do
|
|
| 3327 | + o' <- markEpUniToken o
|
|
| 3340 | 3328 | (e',cs') <- case (fixity, cs) of
|
| 3341 | 3329 | (Infix, (arg1:argrest)) -> do
|
| 3342 | 3330 | arg1' <- markAnnotated arg1
|
| ... | ... | @@ -3348,8 +3336,8 @@ instance ExactPrint (HsCmd GhcPs) where |
| 3348 | 3336 | cs' <- mapM markAnnotated cs
|
| 3349 | 3337 | return (e', cs')
|
| 3350 | 3338 | (Infix, []) -> error "Not possible"
|
| 3351 | - an1 <- markLensBracketsC' an0 lal_brackets
|
|
| 3352 | - return (HsCmdArrForm an1 e' fixity cs')
|
|
| 3339 | + c' <- markEpUniToken c
|
|
| 3340 | + return (HsCmdArrForm (o',c') e' fixity cs')
|
|
| 3353 | 3341 | |
| 3354 | 3342 | exact (HsCmdApp an e1 e2) = do
|
| 3355 | 3343 | e1' <- markAnnotated e1
|
| ... | ... | @@ -4671,9 +4659,11 @@ instance ExactPrint (Pat GhcPs) where |
| 4671 | 4659 | pat' <- markAnnotated pat
|
| 4672 | 4660 | return (BangPat an0 pat')
|
| 4673 | 4661 | |
| 4674 | - exact (ListPat an pats) = do
|
|
| 4675 | - (an', pats') <- markAnnList' an (mapM markAnnotated pats)
|
|
| 4676 | - return (ListPat an' pats')
|
|
| 4662 | + exact (ListPat (os,cs) pats) = do
|
|
| 4663 | + os' <- markEpToken os
|
|
| 4664 | + pats' <- mapM markAnnotated pats
|
|
| 4665 | + cs' <- markEpToken cs
|
|
| 4666 | + return (ListPat (os',cs') pats')
|
|
| 4677 | 4667 | |
| 4678 | 4668 | exact (TuplePat an pats boxity) = do
|
| 4679 | 4669 | an0 <- markOpeningParen an
|
| ... | ... | @@ -342,10 +342,8 @@ insertTopLevelCppComments (HsModule (XModulePs an lo mdeprec mbDoc) mmn mexports |
| 342 | 342 | (xs',rest') = allocPreceding xs rest
|
| 343 | 343 | |
| 344 | 344 | annListBracketsLocs :: AnnListBrackets -> (EpaLocation,EpaLocation)
|
| 345 | -annListBracketsLocs (ListParens o c) = (getEpTokenLoc o, getEpTokenLoc c)
|
|
| 346 | 345 | annListBracketsLocs (ListBraces o c) = (getEpTokenLoc o, getEpTokenLoc c)
|
| 347 | 346 | annListBracketsLocs (ListSquare o c) = (getEpTokenLoc o, getEpTokenLoc c)
|
| 348 | -annListBracketsLocs (ListBanana o c) = (getEpUniTokenLoc o, getEpUniTokenLoc c)
|
|
| 349 | 347 | annListBracketsLocs ListNone = (noAnn, noAnn)
|
| 350 | 348 | |
| 351 | 349 | data SplitWhere = Before | After
|