Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
-
3ec9e2b9
by Mike Pilgrem at 2026-07-31T08:21:33-04:00
-
e5b2a1f7
by sheaf at 2026-07-31T08:22:23-04:00
-
720736e1
by Ben Gamari at 2026-08-01T07:15:36-04:00
-
3d8785ca
by Alan Zimmerman at 2026-08-01T07:15:36-04:00
17 changed files:
- + changelog.d/T27455
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/ThToHs.hs
- docs/users_guide/using.rst
- libraries/base/changelog.md
- libraries/ghc-internal/src/GHC/Internal/Exception/Type.hs
- testsuite/tests/ghc-e/should_run/ghc-e005.stderr
- testsuite/tests/tcplugins/TcPlugin_RewritePerf.hs
- testsuite/tests/tcplugins/TcPlugin_RewritePerf.stderr
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
Changes:
| 1 | +section: base
|
|
| 2 | +issues: #27455
|
|
| 3 | +mrs: !16274
|
|
| 4 | +synopsis:
|
|
| 5 | + Don't drop `ExceptionContext` in `SomeException(toException)`
|
|
| 6 | +description:
|
|
| 7 | + Previously the implementation of ``Exception(toException)`` given to `SomeException` would inappropriately drop the carried `ExceptionContext`. Now ``toException = id``, faithfully implementing the semantics proposed in :ref:`CLC Proposal #200 <https://github.com/haskell/core-libraries-committee/issues/200>`.
|
|
| 8 | + |
| ... | ... | @@ -1158,20 +1158,25 @@ ppDerivStrategy mb = |
| 1158 | 1158 | Nothing -> empty
|
| 1159 | 1159 | Just (L _ ds) -> ppr ds
|
| 1160 | 1160 | |
| 1161 | -ppOverlapPragma :: Maybe (LocatedP (OverlapMode (GhcPass p))) -> SDoc
|
|
| 1161 | +ppOverlapPragma :: forall p. IsPass p => Maybe (LocatedA (OverlapMode (GhcPass p))) -> SDoc
|
|
| 1162 | 1162 | ppOverlapPragma mb =
|
| 1163 | 1163 | case mb of
|
| 1164 | 1164 | Nothing -> empty
|
| 1165 | - Just (L _ (NoOverlap s)) -> maybe_stext s "{-# NO_OVERLAP #-}"
|
|
| 1166 | - Just (L _ (Overlappable s)) -> maybe_stext s "{-# OVERLAPPABLE #-}"
|
|
| 1167 | - Just (L _ (Overlapping s)) -> maybe_stext s "{-# OVERLAPPING #-}"
|
|
| 1168 | - Just (L _ (Overlaps s)) -> maybe_stext s "{-# OVERLAPS #-}"
|
|
| 1169 | - Just (L _ (Incoherent s)) -> maybe_stext s "{-# INCOHERENT #-}"
|
|
| 1170 | - Just (L _ (NonCanonical s)) -> maybe_stext s "{-# INCOHERENT #-}" -- No surface syntax for NONCANONICAL yet
|
|
| 1165 | + Just (L _ (NoOverlap s)) -> maybe_stext (stext s) "{-# NO_OVERLAP #-}"
|
|
| 1166 | + Just (L _ (Overlappable s)) -> maybe_stext (stext s) "{-# OVERLAPPABLE #-}"
|
|
| 1167 | + Just (L _ (Overlapping s)) -> maybe_stext (stext s) "{-# OVERLAPPING #-}"
|
|
| 1168 | + Just (L _ (Overlaps s)) -> maybe_stext (stext s) "{-# OVERLAPS #-}"
|
|
| 1169 | + Just (L _ (Incoherent s)) -> maybe_stext (stext s) "{-# INCOHERENT #-}"
|
|
| 1170 | + Just (L _ (NonCanonical s)) -> maybe_stext (stext s) "{-# INCOHERENT #-}" -- No surface syntax for NONCANONICAL yet
|
|
| 1171 | 1171 | where
|
| 1172 | 1172 | maybe_stext NoSourceText alt = text alt
|
| 1173 | 1173 | maybe_stext (SourceText src) _ = ftext src <+> text "#-}"
|
| 1174 | 1174 | |
| 1175 | + stext :: XOverlapMode (GhcPass p) -> SourceText
|
|
| 1176 | + stext s = case (ghcPass @p, s) of
|
|
| 1177 | + (GhcPs, (s,_)) -> s
|
|
| 1178 | + (GhcRn, (s,_)) -> s
|
|
| 1179 | + (GhcTc, s) -> s
|
|
| 1175 | 1180 | |
| 1176 | 1181 | instance (OutputableBndrId p) => Outputable (InstDecl (GhcPass p)) where
|
| 1177 | 1182 | ppr (ClsInstD { cid_inst = decl }) = ppr decl
|
| ... | ... | @@ -1593,7 +1598,7 @@ type instance Anno (ClsInstDecl (GhcPass p)) = SrcSpanAnnA |
| 1593 | 1598 | type instance Anno (InstDecl (GhcPass p)) = SrcSpanAnnA
|
| 1594 | 1599 | type instance Anno (DocDecl (GhcPass p)) = SrcSpanAnnA
|
| 1595 | 1600 | type instance Anno (DerivDecl (GhcPass p)) = SrcSpanAnnA
|
| 1596 | -type instance Anno (OverlapMode (GhcPass p)) = SrcSpanAnnP
|
|
| 1601 | +type instance Anno (OverlapMode (GhcPass p)) = SrcSpanAnnA
|
|
| 1597 | 1602 | type instance Anno (DerivStrategy (GhcPass p)) = EpAnnCO
|
| 1598 | 1603 | type instance Anno (DefaultDecl (GhcPass p)) = SrcSpanAnnA
|
| 1599 | 1604 | type instance Anno (ForeignDecl (GhcPass p)) = SrcSpanAnnA
|
| ... | ... | @@ -26,6 +26,8 @@ import GHC.Prelude |
| 26 | 26 | |
| 27 | 27 | import GHC.Hs.Extension
|
| 28 | 28 | |
| 29 | +import GHC.Parser.Annotation ( AnnPragma )
|
|
| 30 | + |
|
| 29 | 31 | import Language.Haskell.Syntax.Decls.Overlap
|
| 30 | 32 | import Language.Haskell.Syntax.Extension
|
| 31 | 33 | |
| ... | ... | @@ -65,7 +67,9 @@ instance NFData OverlapFlag where |
| 65 | 67 | instance Outputable OverlapFlag where
|
| 66 | 68 | ppr flag = ppr (overlapMode flag) <+> pprSafeOverlap (isSafeOverlap flag)
|
| 67 | 69 | |
| 68 | -type instance XOverlapMode (GhcPass _) = SourceText
|
|
| 70 | +type instance XOverlapMode GhcPs = (SourceText, AnnPragma)
|
|
| 71 | +type instance XOverlapMode GhcRn = (SourceText, AnnPragma)
|
|
| 72 | +type instance XOverlapMode GhcTc = SourceText
|
|
| 69 | 73 | |
| 70 | 74 | type instance XXOverlapMode (GhcPass _) = DataConCantHappen
|
| 71 | 75 |
| ... | ... | @@ -1752,7 +1752,7 @@ instance ToHie (RScoped (LocatedAn NoEpAnns (DerivStrategy GhcRn))) where |
| 1752 | 1752 | NewtypeStrategy _ -> []
|
| 1753 | 1753 | ViaStrategy s -> [ toHie (TS (ResolvedScopes [sc]) s) ]
|
| 1754 | 1754 | |
| 1755 | -instance ToHie (LocatedP (OverlapMode GhcRn)) where
|
|
| 1755 | +instance ToHie (LocatedA (OverlapMode GhcRn)) where
|
|
| 1756 | 1756 | toHie (L span _) = locOnly (locA span)
|
| 1757 | 1757 | |
| 1758 | 1758 | instance ToHie (LocatedA (ConDecl GhcRn)) where
|
| ... | ... | @@ -1471,15 +1471,15 @@ inst_decl :: { LInstDecl GhcPs } |
| 1471 | 1471 | (fmap reverse $7)
|
| 1472 | 1472 | (AnnDataDefn [] [] NoEpTok tnewtype tdata (epTok $2) dcolon twhere oc cc NoEpTok)}}
|
| 1473 | 1473 | |
| 1474 | -overlap_pragma :: { Maybe (LocatedP (OverlapMode GhcPs)) }
|
|
| 1475 | - : '{-# OVERLAPPABLE' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlappable (getOVERLAPPABLE_PRAGs $1)))
|
|
| 1476 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1477 | - | '{-# OVERLAPPING' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlapping (getOVERLAPPING_PRAGs $1)))
|
|
| 1478 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1479 | - | '{-# OVERLAPS' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlaps (getOVERLAPS_PRAGs $1)))
|
|
| 1480 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1481 | - | '{-# INCOHERENT' '#-}' {% fmap Just $ amsr (sLL $1 $> (Incoherent (getINCOHERENT_PRAGs $1)))
|
|
| 1482 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1474 | +overlap_pragma :: { Maybe (LocatedA (OverlapMode GhcPs)) }
|
|
| 1475 | + : '{-# OVERLAPPABLE' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Overlappable (getOVERLAPPABLE_PRAGs $1,
|
|
| 1476 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1477 | + | '{-# OVERLAPPING' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Overlapping (getOVERLAPPING_PRAGs $1,
|
|
| 1478 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1479 | + | '{-# OVERLAPS' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Overlaps (getOVERLAPS_PRAGs $1,
|
|
| 1480 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1481 | + | '{-# INCOHERENT' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Incoherent (getINCOHERENT_PRAGs $1,
|
|
| 1482 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1483 | 1483 | | {- empty -} { Nothing }
|
| 1484 | 1484 | |
| 1485 | 1485 | deriv_strategy_no_via :: { LDerivStrategy GhcPs }
|
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
|
| 12 | 12 | |
| 13 | 13 | -- | Handles @deriving@ clauses on @data@ declarations.
|
| 14 | -module GHC.Tc.Deriv ( tcDeriving, DerivInfo(..) ) where
|
|
| 14 | +module GHC.Tc.Deriv ( tcDeriving, DerivInfo(..), tcOverlapMode ) where
|
|
| 15 | 15 | |
| 16 | 16 | import GHC.Prelude
|
| 17 | 17 | |
| ... | ... | @@ -776,12 +776,12 @@ deriveStandalone (L loc (DerivDecl (warn, _) deriv_ty mb_lderiv_strat overlap_mo |
| 776 | 776 | |
| 777 | 777 | tcOverlapMode :: OverlapMode GhcRn -> OverlapMode GhcTc
|
| 778 | 778 | tcOverlapMode = \case
|
| 779 | - NoOverlap s -> NoOverlap s
|
|
| 780 | - Overlappable s -> Overlappable s
|
|
| 781 | - Overlapping s -> Overlapping s
|
|
| 782 | - Overlaps s -> Overlaps s
|
|
| 783 | - Incoherent s -> Incoherent s
|
|
| 784 | - NonCanonical s -> NonCanonical s
|
|
| 779 | + NoOverlap s -> NoOverlap (fst s)
|
|
| 780 | + Overlappable s -> Overlappable (fst s)
|
|
| 781 | + Overlapping s -> Overlapping (fst s)
|
|
| 782 | + Overlaps s -> Overlaps (fst s)
|
|
| 783 | + Incoherent s -> Incoherent (fst s)
|
|
| 784 | + NonCanonical s -> NonCanonical (fst s)
|
|
| 785 | 785 | |
| 786 | 786 | -- Typecheck the type in a standalone deriving declaration.
|
| 787 | 787 | --
|
| ... | ... | @@ -558,7 +558,7 @@ tcClsInstDecl (L loc (ClsInstDecl { cid_poly_ty = hs_ty |
| 558 | 558 | -- Dfun location is that of instance *header*
|
| 559 | 559 | |
| 560 | 560 | ; let warn = fmap unLoc lwarn
|
| 561 | - ; ispec <- newClsInst (fmap unLoc overlap_mode) dfun_name
|
|
| 561 | + ; ispec <- newClsInst (fmap (tcOverlapMode . unLoc) overlap_mode) dfun_name
|
|
| 562 | 562 | tyvars theta clas inst_tys warn
|
| 563 | 563 | |
| 564 | 564 | ; let inst_binds = InstBindings
|
| ... | ... | @@ -72,7 +72,6 @@ import GHC.Rename.Utils( mkRnSyntaxExpr ) |
| 72 | 72 | import GHC.Types.Id.Make( mkDictFunId )
|
| 73 | 73 | import GHC.Types.Arity ( Arity, VisArity )
|
| 74 | 74 | import GHC.Types.Basic ( TypeOrKind(..) )
|
| 75 | -import GHC.Types.SourceText
|
|
| 76 | 75 | import GHC.Types.SrcLoc as SrcLoc
|
| 77 | 76 | import GHC.Types.Var.Env
|
| 78 | 77 | import GHC.Types.Id
|
| ... | ... | @@ -912,7 +911,7 @@ hasFixedRuntimeRepRes std_nm user_expr ty = mapM_ do_check mb_arity |
| 912 | 911 | ************************************************************************
|
| 913 | 912 | -}
|
| 914 | 913 | |
| 915 | -getOverlapFlag :: Maybe (OverlapMode (GhcPass p)) -- User pragma if any
|
|
| 914 | +getOverlapFlag :: Maybe (OverlapMode GhcTc) -- User pragma if any
|
|
| 916 | 915 | -> TcM OverlapFlag
|
| 917 | 916 | -- Construct the OverlapFlag from the global module flags,
|
| 918 | 917 | -- but if the overlap_mode argument is (Just m),
|
| ... | ... | @@ -936,9 +935,9 @@ getOverlapFlag overlap_mode_prag |
| 936 | 935 | |
| 937 | 936 | overlap_mode
|
| 938 | 937 | | Just m <- overlap_mode_prag = m
|
| 939 | - | incoherent_ok = Incoherent NoSourceText
|
|
| 940 | - | overlap_ok = Overlaps NoSourceText
|
|
| 941 | - | otherwise = NoOverlap NoSourceText
|
|
| 938 | + | incoherent_ok = Incoherent noAnn
|
|
| 939 | + | overlap_ok = Overlaps noAnn
|
|
| 940 | + | otherwise = NoOverlap noAnn
|
|
| 942 | 941 | |
| 943 | 942 | -- final_overlap_mode: the `-fspecialise-incoherents` flag controls the
|
| 944 | 943 | -- meaning of the `Incoherent` overlap mode: as either an Incoherent overlap
|
| ... | ... | @@ -964,7 +963,7 @@ tcGetInsts :: TcM [ClsInst] |
| 964 | 963 | -- Gets the local class instances.
|
| 965 | 964 | tcGetInsts = fmap tcg_insts getGblEnv
|
| 966 | 965 | |
| 967 | -newClsInst :: Maybe (OverlapMode (GhcPass p)) -- User pragma
|
|
| 966 | +newClsInst :: Maybe (OverlapMode GhcTc) -- User pragma
|
|
| 968 | 967 | -> Name -> [TyVar] -> ThetaType
|
| 969 | 968 | -> Class -> [Type] -> Maybe (WarningTxt GhcRn) -> TcM ClsInst
|
| 970 | 969 | newClsInst overlap_mode dfun_name tvs theta clas tys warn
|
| ... | ... | @@ -356,10 +356,10 @@ cvtDec (InstanceD o ctxt ty decs) |
| 356 | 356 | where
|
| 357 | 357 | overlap pragma =
|
| 358 | 358 | case pragma of
|
| 359 | - TH.Overlaps -> Hs.Overlaps (SourceText $ fsLit "{-# OVERLAPS")
|
|
| 360 | - TH.Overlappable -> Hs.Overlappable (SourceText $ fsLit "{-# OVERLAPPABLE")
|
|
| 361 | - TH.Overlapping -> Hs.Overlapping (SourceText $ fsLit "{-# OVERLAPPING")
|
|
| 362 | - TH.Incoherent -> Hs.Incoherent (SourceText $ fsLit "{-# INCOHERENT")
|
|
| 359 | + TH.Overlaps -> Hs.Overlaps (SourceText $ fsLit "{-# OVERLAPS", noAnn)
|
|
| 360 | + TH.Overlappable -> Hs.Overlappable (SourceText $ fsLit "{-# OVERLAPPABLE", noAnn)
|
|
| 361 | + TH.Overlapping -> Hs.Overlapping (SourceText $ fsLit "{-# OVERLAPPING", noAnn)
|
|
| 362 | + TH.Incoherent -> Hs.Incoherent (SourceText $ fsLit "{-# INCOHERENT", noAnn)
|
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 |
| ... | ... | @@ -58,9 +58,10 @@ Windows. |
| 58 | 58 | Options overview
|
| 59 | 59 | ----------------
|
| 60 | 60 | |
| 61 | -GHC's behaviour is controlled by options, which for historical reasons
|
|
| 62 | -are also sometimes referred to as command-line flags or arguments.
|
|
| 63 | -Options can be specified in three ways:
|
|
| 61 | +GHC's behaviour is controlled by options. Options can be specified in four ways:
|
|
| 62 | +(1) directly on the command line; (2) via files (response files); (3) in source
|
|
| 63 | +files, using a pragma; and (4) when using GHCi, from within GHCi.
|
|
| 64 | + |
|
| 64 | 65 | |
| 65 | 66 | Command-line arguments
|
| 66 | 67 | ~~~~~~~~~~~~~~~~~~~~~~
|
| ... | ... | @@ -76,7 +77,8 @@ An invocation of GHC takes the following form: |
| 76 | 77 | |
| 77 | 78 | ghc [argument...]
|
| 78 | 79 | |
| 79 | -Command-line arguments are either options or file names.
|
|
| 80 | +Command-line arguments are either options, file names or response file arguments
|
|
| 81 | +(see further below).
|
|
| 80 | 82 | |
| 81 | 83 | Command-line options begin with ``-``. They may *not* be grouped:
|
| 82 | 84 | ``-vO`` is different from ``-v -O``. Options need not precede filenames:
|
| ... | ... | @@ -111,16 +113,47 @@ to the files ``Foo.hs`` and ``Bar.hs``. |
| 111 | 113 | Command-line arguments in response files
|
| 112 | 114 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 113 | 115 | |
| 114 | -In addition to passing arguments via the command-line, arguments can be passed
|
|
| 115 | -via GNU-style response files. For instance,
|
|
| 116 | +GHC's use of response files is similar to that of GCC. A response file argument
|
|
| 117 | +is ``@`` followed immediately by the absolute or relative path identifying the
|
|
| 118 | +response file.
|
|
| 119 | + |
|
| 120 | +.. note::
|
|
| 121 | + |
|
| 122 | + In PowerShell, ``@`` is used to identify a splatting variable. Consequently,
|
|
| 123 | + GHC response file arguments must be enclosed in quotation marks on the
|
|
| 124 | + command line to avoid parsing errors.
|
|
| 125 | + |
|
| 126 | +A response file argument is equivalent to the command-line arguments in the
|
|
| 127 | +response file in the order that they appear in the file. A response file can
|
|
| 128 | +include a response file argument.
|
|
| 129 | + |
|
| 130 | +In a response file:
|
|
| 131 | + |
|
| 132 | +* any unescaped whitespace is assumed to separate command-line arguments and is
|
|
| 133 | + otherwise ignored;
|
|
| 134 | +* a backslash character (``\``) always escapes the following character; and
|
|
| 135 | +* matching pairs of unescaped single quote (``'``) or double quote (``"``)
|
|
| 136 | + characters escape blocks of characters.
|
|
| 137 | + |
|
| 138 | +For example,
|
|
| 116 | 139 | |
| 117 | 140 | .. code-block:: bash
|
| 118 | 141 | |
| 119 | - $ cat response-file
|
|
| 142 | + $ cat response-file1
|
|
| 120 | 143 | -O1
|
| 144 | + @response-file2
|
|
| 145 | + |
|
| 146 | + $ cat response-file2
|
|
| 121 | 147 | Hello.hs
|
| 122 | 148 | -o Hello
|
| 123 | - $ ghc @response-file
|
|
| 149 | + |
|
| 150 | + $ ghc @response-file1
|
|
| 151 | + |
|
| 152 | +is equivalent to,
|
|
| 153 | + |
|
| 154 | +.. code-block:: bash
|
|
| 155 | + |
|
| 156 | + $ ghc -O1 Hello.hs -o Hello
|
|
| 124 | 157 | |
| 125 | 158 | .. _source-file-options:
|
| 126 | 159 |
| ... | ... | @@ -38,6 +38,7 @@ |
| 38 | 38 | * Show `ExceptionContext` in `displayExceptionAnnotation` implementation of `WhileHandling` ([GHC #27456](https://gitlab.haskell.org/ghc/ghc/-/issues/27456))
|
| 39 | 39 | * Hide implementation details when throwing exceptions in throw and throwSTM. ([CLC proposal #387](https://github.com/haskell/core-libraries-committee/issues/387))
|
| 40 | 40 | * Change `hIsReadable` and `hIsWritable` such that they always throw a respective exception when encountering a closed or semi-closed handle, not just in the case of a file handle. ([CLC proposal #371](github.com/haskell/core-libraries-committee/issues/371))
|
| 41 | + * The implementation of `toException` in `SomeException`'s `Exception` instance no longer drops exception context, in keeping with the behavior originally proposed in [CLC Proposal #200](https://github.com/haskell/core-libraries-committee/issues/200).
|
|
| 41 | 42 | * Annotate `onException` continuation with `WhileHandling`. ([CLC Proposal #397](https://github.com/haskell/core-libraries-committee/issues/397))
|
| 42 | 43 | * Improve error message for `Data.Char.chr`. ([CLC Proposal #384](https://github.com/haskell/core-libraries-committee/issues/384))
|
| 43 | 44 |
| ... | ... | @@ -55,7 +55,7 @@ import GHC.Internal.Data.Maybe |
| 55 | 55 | import GHC.Internal.Data.Typeable (Typeable, TypeRep, cast)
|
| 56 | 56 | import qualified GHC.Internal.Data.Typeable as Typeable
|
| 57 | 57 | -- loop: GHC.Internal.Data.Typeable -> GHC.Internal.Err -> GHC.Internal.Exception
|
| 58 | -import GHC.Internal.Base (String, Void, fmap, return, ($), (.), (++))
|
|
| 58 | +import GHC.Internal.Base (String, Void, fmap, return, ($), (.), (++), id)
|
|
| 59 | 59 | import GHC.Internal.Show
|
| 60 | 60 | import GHC.Internal.Types (Bool(..))
|
| 61 | 61 | import GHC.Internal.Exception.Context
|
| ... | ... | @@ -208,7 +208,16 @@ Caught MismatchedParentheses |
| 208 | 208 | |
| 209 | 209 | -}
|
| 210 | 210 | class (Typeable e, Show e) => Exception e where
|
| 211 | - -- | @toException@ should produce a 'SomeException' with no attached 'ExceptionContext'.
|
|
| 211 | + -- | 'toException' converts an exception into the existential 'SomeException'
|
|
| 212 | + -- wrapper type.
|
|
| 213 | + --
|
|
| 214 | + -- In doing so, 'toException' should not /add/ an 'ExceptionContext'.
|
|
| 215 | + --
|
|
| 216 | + -- - In most cases, the exception does not store its own 'ExceptionContext'.
|
|
| 217 | + -- The default implementation of 'toException' (which does not store any
|
|
| 218 | + -- 'ExceptionContext') is suitable for these cases.
|
|
| 219 | + -- - In the rare case that the exception itself stores an 'ExceptionContext',
|
|
| 220 | + -- this context should be preserved by 'toException'.
|
|
| 212 | 221 | toException :: e -> SomeException
|
| 213 | 222 | fromException :: SomeException -> Maybe e
|
| 214 | 223 | |
| ... | ... | @@ -231,13 +240,11 @@ class (Typeable e, Show e) => Exception e where |
| 231 | 240 | -- | @since base-4.8.0.0
|
| 232 | 241 | instance Exception Void
|
| 233 | 242 | |
| 234 | --- | This drops any attached 'ExceptionContext'.
|
|
| 243 | +-- | NB: this instance preserves the attached 'ExceptionContext'.
|
|
| 235 | 244 | --
|
| 236 | 245 | -- @since base-3.0
|
| 237 | 246 | instance Exception SomeException where
|
| 238 | - toException (SomeException e) =
|
|
| 239 | - let ?exceptionContext = emptyExceptionContext
|
|
| 240 | - in SomeException e
|
|
| 247 | + toException = id
|
|
| 241 | 248 | fromException = Just
|
| 242 | 249 | backtraceDesired (SomeException e) = backtraceDesired e
|
| 243 | 250 | displayException (SomeException e) = displayException e
|
| ... | ... | @@ -4,3 +4,8 @@ foo |
| 4 | 4 | |
| 5 | 5 | HasCallStack backtrace:
|
| 6 | 6 | error, called at ghc-e005.hs:12:10 in main:Main
|
| 7 | + |
|
| 8 | + |
|
| 9 | +HasCallStack backtrace:
|
|
| 10 | + throwIO, called at ghc\GHCi\UI.hs:1655:31 in ghc-bin-10.1.20260629-inplace:GHCi.UI
|
|
| 11 | + |
| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | -- Testing performance of type-checking rewriting plugins.
|
| 3 | 3 | -- Test based on T9872b.
|
| 4 | 4 | |
| 5 | -{-# OPTIONS_GHC -dcore-lint #-}
|
|
| 6 | 5 | {-# OPTIONS_GHC -freduction-depth=400 #-}
|
| 7 | 6 | {-# OPTIONS_GHC -fplugin RewritePerfPlugin #-}
|
| 8 | 7 |
| 1 | 1 | [1 of 4] Compiling RewritePerfDefs ( RewritePerfDefs.hs, RewritePerfDefs.o )
|
| 2 | 2 | [2 of 4] Compiling RewritePerfPlugin ( RewritePerfPlugin.hs, RewritePerfPlugin.o )
|
| 3 | 3 | [3 of 4] Compiling Main ( TcPlugin_RewritePerf.hs, TcPlugin_RewritePerf.o )
|
| 4 | - |
|
| 5 | -TcPlugin_RewritePerf.hs:25:8: error: [GHC-39999]
|
|
| 4 | +TcPlugin_RewritePerf.hs:24:8: error: [GHC-39999]
|
|
| 6 | 5 | • No instance for ‘Show
|
| 7 | 6 | (Proxy
|
| 8 | 7 | [['Cube G B W R B G, 'Cube W G B W R R, 'Cube R W R B G R,
|
| ... | ... | @@ -25,3 +24,4 @@ TcPlugin_RewritePerf.hs:25:8: error: [GHC-39999] |
| 25 | 24 | • In the expression: print (Proxy :: Proxy (Solutions Cubes))
|
| 26 | 25 | In an equation for ‘main’:
|
| 27 | 26 | main = print (Proxy :: Proxy (Solutions Cubes))
|
| 27 | + |
| ... | ... | @@ -2246,40 +2246,40 @@ instance ExactPrint (TyFamInstDecl GhcPs) where |
| 2246 | 2246 | |
| 2247 | 2247 | -- ---------------------------------------------------------------------
|
| 2248 | 2248 | |
| 2249 | -instance Typeable p => ExactPrint (LocatedP (OverlapMode (GhcPass p))) where
|
|
| 2250 | - getAnnotationEntry = entryFromLocatedA
|
|
| 2251 | - setAnnotationAnchor = setAnchorAn
|
|
| 2249 | +instance ExactPrint (OverlapMode GhcPs) where
|
|
| 2250 | + getAnnotationEntry _ = NoEntryVal
|
|
| 2251 | + setAnnotationAnchor a _ _ _ = a
|
|
| 2252 | 2252 | |
| 2253 | 2253 | -- NOTE: NoOverlap is only used in the typechecker
|
| 2254 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (NoOverlap src)) = do
|
|
| 2254 | + exact (NoOverlap (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2255 | 2255 | o' <- markAnnOpen'' o src "{-# NO_OVERLAP"
|
| 2256 | 2256 | c' <- markEpToken c
|
| 2257 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (NoOverlap src))
|
|
| 2257 | + return (NoOverlap (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2258 | 2258 | |
| 2259 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Overlappable src)) = do
|
|
| 2259 | + exact (Overlappable (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2260 | 2260 | o' <- markAnnOpen'' o src "{-# OVERLAPPABLE"
|
| 2261 | 2261 | c' <- markEpToken c
|
| 2262 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Overlappable src))
|
|
| 2262 | + return (Overlappable (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2263 | 2263 | |
| 2264 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Overlapping src)) = do
|
|
| 2264 | + exact (Overlapping (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2265 | 2265 | o' <- markAnnOpen'' o src "{-# OVERLAPPING"
|
| 2266 | 2266 | c' <- markEpToken c
|
| 2267 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Overlapping src))
|
|
| 2267 | + return (Overlapping (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2268 | 2268 | |
| 2269 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Overlaps src)) = do
|
|
| 2269 | + exact (Overlaps (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2270 | 2270 | o' <- markAnnOpen'' o src "{-# OVERLAPS"
|
| 2271 | 2271 | c' <- markEpToken c
|
| 2272 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Overlaps src))
|
|
| 2272 | + return (Overlaps (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2273 | 2273 | |
| 2274 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Incoherent src)) = do
|
|
| 2274 | + exact (Incoherent (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2275 | 2275 | o' <- markAnnOpen'' o src "{-# INCOHERENT"
|
| 2276 | 2276 | c' <- markEpToken c
|
| 2277 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Incoherent src))
|
|
| 2277 | + return (Incoherent (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2278 | 2278 | |
| 2279 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (NonCanonical src)) = do
|
|
| 2279 | + exact (NonCanonical (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2280 | 2280 | o' <- markAnnOpen'' o src "{-# INCOHERENT"
|
| 2281 | 2281 | c' <- markEpToken c
|
| 2282 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Incoherent src))
|
|
| 2282 | + return (Incoherent (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2283 | 2283 | |
| 2284 | 2284 | -- ---------------------------------------------------------------------
|
| 2285 | 2285 |
| ... | ... | @@ -836,7 +836,7 @@ type instance Anno (FamilyResultSig DocNameI) = EpAnn NoEpAnns |
| 836 | 836 | type instance Anno (HsOuterTyVarBndrs Specificity DocNameI) = SrcSpanAnnA
|
| 837 | 837 | type instance Anno (HsSigType DocNameI) = SrcSpanAnnA
|
| 838 | 838 | type instance Anno (BooleanFormula DocNameI) = SrcSpanAnnBF
|
| 839 | -type instance Anno (OverlapMode DocNameI) = EpAnn AnnPragma
|
|
| 839 | +type instance Anno (OverlapMode DocNameI) = SrcSpanAnnA
|
|
| 840 | 840 | type instance Anno (CType DocNameI) = EpAnn AnnPragma
|
| 841 | 841 | type instance Anno (Header DocNameI) = EpAnn AnnPragma
|
| 842 | 842 | type instance Anno (HsModifierOf (LocatedA (HsType DocNameI)) DocNameI) = SrcSpanAnnA
|