[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Check for negative type literals in the type checker (#26861)
by Marge Bot (@marge-bot) 27 Feb '26
by Marge Bot (@marge-bot) 27 Feb '26
27 Feb '26
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
bd3eba86 by Vladislav Zavialov at 2026-02-27T05:48:01-05:00
Check for negative type literals in the type checker (#26861)
GHC disallows negative type literals (e.g., -1), as tested by T8306 and
T8412. This check is currently performed in the renamer:
rnHsTyLit tyLit@(HsNumTy x i) = do
when (i < 0) $
addErr $ TcRnNegativeNumTypeLiteral tyLit
However, this check can be bypassed using RequiredTypeArguments
(see the new test case T26861). Prior to this patch, such programs
caused the compiler to hang instead of reporting a proper error.
This patch addresses the issue by adding an equivalent check in
the type checker, namely in tcHsType.
The diff is deliberately minimal to facilitate backporting. A more
comprehensive rework of HsTyLit is planned for a separate commit.
- - - - -
faf14e0c by Vladislav Zavialov at 2026-02-27T05:48:45-05:00
Consistent pretty-printing of HsString, HsIsString, HsStrTy
Factor out a helper to pretty-print string literals, thus fixing newline
handling for overloaded string literals and type literals.
Test cases: T26860ppr T26860ppr_overloaded T26860ppr_tylit
Follow up to ddf1434ff9bb08cfef3c93f23de6b83ec698aa27
- - - - -
688af3fb by Arnaud Spiwack at 2026-02-27T06:22:19-05:00
Make list comprehension completely non-linear
Fixes #25081
From the note:
The usefulness of list comprehension in conjunction with linear types is dubious.
After all, statements are made to be run many times, for instance in
```haskell
[u | y <- [0,1], stmts]
```
both `u` and `stmts` are going to be run several times.
In principle, though, there are some position in a monad comprehension
expression which could be considered linear. We could try and make it so that
these positions are considered linear by the typechecker, but in practice the
desugarer doesn't take enough care to ensure that these are indeed desugared to
linear sites. We tried in the past, and it turned out that we'd miss a
desugaring corner case (#25772).
Until there's a demand for this very specific improvement, let's instead be
conservative, and consider list comprehension to be completely non-linear.
- - - - -
b22799ca by Simon Jakobi at 2026-02-27T06:22:23-05:00
PmAltConSet: Use Data.Set instead of Data.Map
...to store `PmLit`s.
The Map was only used to map keys to themselves.
Changing the Map to a Set saves a Word of memory per entry.
Resolves #26756.
- - - - -
17 changed files:
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Match.hs
- − testsuite/tests/linear/should_compile/LinearListComprehension.hs
- testsuite/tests/linear/should_compile/all.T
- testsuite/tests/linear/should_fail/T25081.hs
- testsuite/tests/linear/should_fail/T25081.stderr
- + testsuite/tests/parser/should_fail/T26860ppr_overloaded.hs
- + testsuite/tests/parser/should_fail/T26860ppr_overloaded.stderr
- + testsuite/tests/parser/should_fail/T26860ppr_tylit.hs
- + testsuite/tests/parser/should_fail/T26860ppr_tylit.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/typecheck/should_fail/T26861.hs
- + testsuite/tests/typecheck/should_fail/T26861.stderr
- testsuite/tests/typecheck/should_fail/all.T
Changes:
=====================================
compiler/GHC/Hs/Lit.hs
=====================================
@@ -21,7 +21,7 @@ import GHC.Prelude
import {-# SOURCE #-} GHC.Hs.Expr( pprExpr )
-import GHC.Data.FastString (unpackFS)
+import GHC.Data.FastString (FastString, unpackFS)
import GHC.Types.Basic (PprPrec(..), topPrec )
import GHC.Core.Ppr ( {- instance OutputableBndr TyVar -} )
import GHC.Types.SourceText
@@ -209,10 +209,7 @@ Equivalently it's True if
instance IsPass p => Outputable (HsLit (GhcPass p)) where
ppr (HsChar st c) = pprWithSourceText st (pprHsChar c)
ppr (HsCharPrim st c) = pprWithSourceText st (pprPrimChar c)
- ppr (HsString st s) =
- case st of
- NoSourceText -> pprHsString s
- SourceText src -> vcat $ map text $ split '\n' (unpackFS src)
+ ppr (HsString st s) = pprHsStringLit st s
ppr (HsStringPrim st s) = pprWithSourceText st (pprHsBytes s)
ppr (HsInt _ i)
= pprWithSourceText (il_text i) (integer (il_value i))
@@ -233,6 +230,10 @@ instance IsPass p => Outputable (HsLit (GhcPass p)) where
(HsInteger st i _) -> pprWithSourceText st (integer i)
(HsRat f _) -> ppr f
+pprHsStringLit :: SourceText -> FastString -> SDoc
+pprHsStringLit NoSourceText s = pprHsString s
+pprHsStringLit (SourceText src) _ = vcat $ map text $ split '\n' (unpackFS src)
+
-- in debug mode, print the expression that it's resolved to, too
instance OutputableBndrId p
=> Outputable (HsOverLit (GhcPass p)) where
@@ -242,7 +243,7 @@ instance OutputableBndrId p
instance Outputable OverLitVal where
ppr (HsIntegral i) = pprWithSourceText (il_text i) (integer (il_value i))
ppr (HsFractional f) = ppr f
- ppr (HsIsString st s) = pprWithSourceText st (pprHsString s)
+ ppr (HsIsString st s) = pprHsStringLit st s
negateOverLitVal :: OverLitVal -> OverLitVal
negateOverLitVal (HsIntegral i) = HsIntegral (negateIntegralLit i)
=====================================
compiler/GHC/Hs/Type.hs
=====================================
@@ -116,6 +116,7 @@ import GHC.Core.Ppr ( pprOccWithTick)
import GHC.Core.Type
import GHC.Core.Multiplicity( pprArrowWithMultiplicity )
import GHC.Hs.Doc
+import GHC.Hs.Lit (pprHsStringLit)
import GHC.Generics (Generic, Generically(..))
import GHC.Types.Basic
import GHC.Types.SrcLoc
@@ -1346,7 +1347,7 @@ instance (OutputableBndrId pass) => OutputableBndr (GenLocated SrcSpan (FieldOcc
ppr_tylit :: (HsTyLit (GhcPass p)) -> SDoc
ppr_tylit (HsNumTy source i) = pprWithSourceText source (integer i)
-ppr_tylit (HsStrTy source s) = pprWithSourceText source (text (show s))
+ppr_tylit (HsStrTy source s) = pprHsStringLit source s
ppr_tylit (HsCharTy source c) = pprWithSourceText source (text (show c))
pprAnonWildCard :: SDoc
=====================================
compiler/GHC/HsToCore/Pmc/Solver/Types.hs
=====================================
@@ -75,7 +75,7 @@ import GHC.Generics (Generic, Generically(..))
import Numeric (fromRat)
import Data.Ratio
import Data.List( find )
-import qualified Data.Map as FM
+import qualified Data.Set as Set
import GHC.Real (Ratio(..))
import qualified Data.Semigroup as S
@@ -388,7 +388,7 @@ data PmLitValue
| PmLitOverString FastString
-- | Syntactic equality.
--- We want (Ord PmLit) so that we can use (Map PmLit x) in `PmAltConSet`
+-- We want (Ord PmLit) so that we can use (Set PmLit) in `PmAltConSet`
instance Eq PmLit where
a == b = (a `compare` b) == EQ
instance Ord PmLit where
@@ -510,34 +510,34 @@ data PmAltCon = PmAltConLike ConLike
| PmAltLit PmLit
data PmAltConSet = PACS !(UniqDSet ConLike)
- !(FM.Map PmLit PmLit)
--- We use a (FM.Map PmLit PmLit) here, at the cost of requiring an Ord
+ !(Set.Set PmLit)
+-- We use a (Data.Set.Set PmLit) here, at the cost of requiring an Ord
-- instance for PmLit, because in extreme cases the set of PmLits can be
-- very large. See #26514.
emptyPmAltConSet :: PmAltConSet
-emptyPmAltConSet = PACS emptyUniqDSet FM.empty
+emptyPmAltConSet = PACS emptyUniqDSet Set.empty
isEmptyPmAltConSet :: PmAltConSet -> Bool
isEmptyPmAltConSet (PACS cls lits)
- = isEmptyUniqDSet cls && FM.null lits
+ = isEmptyUniqDSet cls && Set.null lits
-- | Whether there is a 'PmAltCon' in the 'PmAltConSet' that compares 'Equal' to
-- the given 'PmAltCon' according to 'eqPmAltCon'.
elemPmAltConSet :: PmAltCon -> PmAltConSet -> Bool
elemPmAltConSet (PmAltConLike cl) (PACS cls _ ) = elementOfUniqDSet cl cls
-elemPmAltConSet (PmAltLit lit) (PACS _ lits) = isJust (FM.lookup lit lits)
+elemPmAltConSet (PmAltLit lit) (PACS _ lits) = Set.member lit lits
extendPmAltConSet :: PmAltConSet -> PmAltCon -> PmAltConSet
extendPmAltConSet (PACS cls lits) (PmAltConLike cl)
= PACS (addOneToUniqDSet cls cl) lits
extendPmAltConSet (PACS cls lits) (PmAltLit lit)
- = PACS cls (FM.insert lit lit lits)
+ = PACS cls (Set.insert lit lits)
pmAltConSetElems :: PmAltConSet -> [PmAltCon]
pmAltConSetElems (PACS cls lits)
= map PmAltConLike (uniqDSetToList cls) ++
- FM.foldr ((:) . PmAltLit) [] lits
+ map PmAltLit (Set.toList lits)
instance Outputable PmAltConSet where
ppr = ppr . pmAltConSetElems
=====================================
compiler/GHC/Tc/Gen/HsType.hs
=====================================
@@ -1264,8 +1264,10 @@ tcHsType _ rn_ty@(HsStarTy _ _) exp_kind
= checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind
--------- Literals
-tcHsType _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind
- = do { checkWiredInTyCon naturalTyCon
+tcHsType _ rn_ty@(HsTyLit _ (HsNumTy x n)) exp_kind
+ = do { when (n < 0) $
+ addErr $ TcRnNegativeNumTypeLiteral (HsNumTy x n)
+ ; checkWiredInTyCon naturalTyCon
; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind }
tcHsType _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind
=====================================
compiler/GHC/Tc/Gen/Match.hs
=====================================
@@ -543,9 +543,29 @@ tcGuardStmt _ stmt _ _
-- potential for non-trivial coercions in tcMcStmt
{-
-Note [Binding in list comprehension isn't linear]
+Note [List comprehension isn't linear]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-In principle, [ y | () <- xs, y <- [0,1]] could be linear in `xs`.
+The usefulness of list comprehension in conjunction with linear types is dubious.
+After all, statements are made to be run many times, for instance in
+
+[u | y <- [0,1], stmts]
+
+both u and stmts are going to be run several times.
+
+In principle, though, there are some positions in a monad comprehension
+expressions which could be considered linear. We could try and make it so that
+these positions are considered linear by the typechecker, but in practice the
+desugarer doesn't take enough care to ensure that these are indeed desugared to
+linear sites. We tried in the past, and it turned out that we'd miss a
+desugaring corner case (#25772).
+
+Until there's a demand for this very specific improvement, let's instead be
+conservative, and consider list comprehension to be completely non-linear.
+
+Here are the case where list comprehension could be linear, together with the
+known challenges.
+
+(LCL1) [ y | () <- xs, y <- [0,1]] could be linear in `xs`.
But, the way the desugaring works, we get something like
case xs of
@@ -566,21 +586,31 @@ isn't linear in `xs` since the elements of `xs` are ignored. So we'd still have
to call `tcScalingUsage` on `xs` in `tcLcStmt`, we'd just have to create a fresh
multiplicity variable. We'd also use the same multiplicity variable in the call
to `tcCheckPat` instead of `unrestricted`.
+
+(LCL2) [ y | b, y <- [0,1]] could be linear in `b`. This actually works fine
+with -O0 (as far as anybody knows), but -O and higher desugar list comprehension
+using the `build` combinator (this was the cause of #25772). But `build` isn't
+defined to be linear. The consequences of making `build` linear are
+unknown. It's not worth trying until a real need arises.
+
+(LCL3) [ x | ] could be linear in x. But it's unclear why anybody would want to
+write this instead of [ x ]. Besides, this syntax is currently rejected by the
+parser. The `build` obstacle of (LCL2) applies here too.
-}
tcLcStmt :: TyCon -- The list type constructor ([])
-> TcExprStmtChecker
tcLcStmt _ _ (LastStmt x body noret _) elt_ty thing_inside
- = do { body' <- tcMonoExprNC body elt_ty
+ = do { -- see (LCL3) in Note [List comprehension isn't linear]
+ body' <- tcScalingUsage ManyTy $ tcMonoExprNC body elt_ty
; thing <- thing_inside (panic "tcLcStmt: thing_inside")
; return (LastStmt x body' noret noSyntaxExpr, thing) }
-- A generator, pat <- rhs
tcLcStmt m_tc ctxt (BindStmt _ pat rhs) elt_ty thing_inside
= do { pat_ty <- newFlexiTyVarTy liftedTypeKind
- -- About the next `tcScalingUsage ManyTy` and unrestricted
- -- see Note [Binding in list comprehension isn't linear]
+ -- see (LCL1) in Note [List comprehension isn't linear]
; rhs' <- tcScalingUsage ManyTy $ tcCheckMonoExpr rhs (mkTyConApp m_tc [pat_ty])
; (pat', thing) <- tcCheckPat (StmtCtxt ctxt) pat (unrestricted pat_ty) $
tcScalingUsage ManyTy $
@@ -589,7 +619,9 @@ tcLcStmt m_tc ctxt (BindStmt _ pat rhs) elt_ty thing_inside
-- A boolean guard
tcLcStmt _ _ (BodyStmt _ rhs _ _) elt_ty thing_inside
- = do { rhs' <- tcCheckMonoExpr rhs boolTy
+ = do { -- Regarding the `tcScalingUsage ManyTy` on the `rhs`,
+ -- see (LCL2) in Note [List comprehension isn't linear]
+ rhs' <- tcScalingUsage ManyTy $ tcCheckMonoExpr rhs boolTy
; thing <- tcScalingUsage ManyTy $ thing_inside elt_ty
; return (BodyStmt boolTy rhs' noSyntaxExpr noSyntaxExpr, thing) }
=====================================
testsuite/tests/linear/should_compile/LinearListComprehension.hs deleted
=====================================
@@ -1,14 +0,0 @@
-{-# LANGUAGE LinearTypes #-}
-
-module LinearListComprehension where
-
--- Probably nobody actually cares if monad comprehension realised that it can be
--- linear in the first statement. But it can, so we might as well.
-
-guard :: a %1 -> (a %1 -> Bool) %1 -> [Int]
-guard x g = [ y | g x, y <- [0,1] ]
-
--- This isn't correct syntax, but a singleton list comprehension would
--- presumably work too
--- last :: a %1 -> [a]
--- last x = [ x | ]
=====================================
testsuite/tests/linear/should_compile/all.T
=====================================
@@ -47,7 +47,6 @@ test('LinearRecUpd', normal, compile, [''])
test('T23814', normal, compile, [''])
test('LinearLet', normal, compile, [''])
test('LinearLetPoly', normal, compile, [''])
-test('LinearListComprehension', normal, compile, ['-dlinear-core-lint'])
test('OmitFieldPat', normal, compile, ['-dcore-lint'])
test('T25515', normal, compile, ['-dcore-lint'])
test('T25428', normal, compile, [''])
=====================================
testsuite/tests/linear/should_fail/T25081.hs
=====================================
@@ -22,11 +22,16 @@ guard_bind x = [ () | False, _ <- [x]]
guard_guard :: a %1 -> (a %1 -> Bool) %1 -> [()]
guard_guard x g = [ () | False, g x ]
--- This could, in principle, be linear. But see Note [Binding in list
+-- This could, in principle, be linear. But see (LCL1) in Note [List
-- comprehension isn't linear] in GHC.Tc.Gen.Match.
first_bind :: [()] %1 -> [Int]
first_bind xs = [ y | () <- xs, y <- [0,1]]
+-- This could, in principle, be linear. But see (LCL2) in Note [List
+-- comprehension isn't linear] in GHC.Tc.Gen.Match.
+first_guard :: a %1 -> (a %1 -> Bool) %1 -> [Int]
+first_guard x g = [ y | g x, y <- [0,1] ]
+
parallel :: a %1 -> [(a, Bool)]
parallel x = [(y,z) | y <- [x] | z <- [True]]
=====================================
testsuite/tests/linear/should_fail/T25081.stderr
=====================================
@@ -44,20 +44,32 @@ T25081.hs:28:12: error: [GHC-18872]
• In an equation for ‘first_bind’:
first_bind xs = [y | () <- xs, y <- [0, 1]]
-T25081.hs:31:10: error: [GHC-18872]
+T25081.hs:33:13: error: [GHC-18872]
+ • Couldn't match type ‘Many’ with ‘One’
+ arising from multiplicity of ‘x’
+ • In an equation for ‘first_guard’:
+ first_guard x g = [y | g x, y <- [0, 1]]
+
+T25081.hs:33:15: error: [GHC-18872]
+ • Couldn't match type ‘Many’ with ‘One’
+ arising from multiplicity of ‘g’
+ • In an equation for ‘first_guard’:
+ first_guard x g = [y | g x, y <- [0, 1]]
+
+T25081.hs:36:10: error: [GHC-18872]
• Couldn't match type ‘Many’ with ‘One’
arising from multiplicity of ‘x’
• In an equation for ‘parallel’:
parallel x = [(y, z) | y <- [x] | z <- [True]]
-T25081.hs:34:16: error: [GHC-18872]
+T25081.hs:39:16: error: [GHC-18872]
• Couldn't match type ‘Many’ with ‘One’
arising from multiplicity of ‘x’
• In an equation for ‘parallel_guard’:
parallel_guard x g
= [(y, z) | g x, y <- [0, 1] | z <- [True, False]]
-T25081.hs:37:11: error: [GHC-18872]
+T25081.hs:42:11: error: [GHC-18872]
• Couldn't match type ‘Many’ with ‘One’
arising from multiplicity of ‘x’
• In an equation for ‘transform’:
=====================================
testsuite/tests/parser/should_fail/T26860ppr_overloaded.hs
=====================================
@@ -0,0 +1,11 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module T26860ppr_overloaded where
+
+-- Test that the error message containing the string literal is well-formatted.
+-- See also: parser/should_fail/MultilineStringsError
+x :: Int
+x = "first line \
+ \asdf\n\
+ \second line"
+
=====================================
testsuite/tests/parser/should_fail/T26860ppr_overloaded.stderr
=====================================
@@ -0,0 +1,14 @@
+T26860ppr_overloaded.hs:8:5: error: [GHC-39999]
+ • No instance for ‘GHC.Internal.Data.String.IsString Int’
+ arising from the literal ‘"first line \
+ \asdf\n\
+ \second line"’
+ • In the expression:
+ "first line \
+ \asdf\n\
+ \second line"
+ In an equation for ‘x’:
+ x = "first line \
+ \asdf\n\
+ \second line"
+
=====================================
testsuite/tests/parser/should_fail/T26860ppr_tylit.hs
=====================================
@@ -0,0 +1,13 @@
+{-# LANGUAGE DataKinds #-}
+
+module T26860ppr_tylit where
+
+import Data.Kind (Type)
+
+-- Test that the error message containing the string literal is well-formatted.
+-- See also: parser/should_fail/MultilineStringsError
+type X :: Type
+type X = "first line \
+ \asdf\n\
+ \second line"
+
=====================================
testsuite/tests/parser/should_fail/T26860ppr_tylit.stderr
=====================================
@@ -0,0 +1,11 @@
+T26860ppr_tylit.hs:10:10: error: [GHC-83865]
+ • Expected a type,
+ but ‘"first line \
+ \asdf\n\
+ \second line"’ has kind
+ ‘GHC.Internal.Types.Symbol’
+ • In the type ‘"first line \
+ \asdf\n\
+ \second line"’
+ In the type synonym declaration for ‘X’
+
=====================================
testsuite/tests/parser/should_fail/all.T
=====================================
@@ -245,3 +245,5 @@ test('T26418', normal, compile_fail, [''])
test('T12488c', normal, compile_fail, [''])
test('T12488d', normal, compile_fail, [''])
test('T26860ppr', normal, compile_fail, [''])
+test('T26860ppr_overloaded', normal, compile_fail, [''])
+test('T26860ppr_tylit', normal, compile_fail, [''])
=====================================
testsuite/tests/typecheck/should_fail/T26861.hs
=====================================
@@ -0,0 +1,14 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE NegativeLiterals #-}
+{-# LANGUAGE RequiredTypeArguments #-}
+
+module T26861 where
+
+import Data.Proxy
+import GHC.TypeLits
+
+main :: IO ()
+main = print (natVis (-42))
+
+natVis :: forall a -> KnownNat a => Integer
+natVis n = natVal (Proxy @n)
=====================================
testsuite/tests/typecheck/should_fail/T26861.stderr
=====================================
@@ -0,0 +1,6 @@
+T26861.hs:11:23: error: [GHC-93632]
+ • Illegal literal in type (type literals must not be negative): -42
+ • In the type ‘-42’
+ In the first argument of ‘print’, namely ‘(natVis (-42))’
+ In the expression: print (natVis (-42))
+
=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -752,3 +752,4 @@ test('T23162a', normal, compile_fail, [''])
test('T23162b', normal, compile_fail, [''])
test('T23162c', normal, compile, [''])
test('T23162d', normal, compile, [''])
+test('T26861', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21828b5893978bd3e07418599e30a7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/21828b5893978bd3e07418599e30a7…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/int-index/drop-tylit] 5 commits: wasm: add /assets endpoint to serve user-specified assets
by Vladislav Zavialov (@int-index) 27 Feb '26
by Vladislav Zavialov (@int-index) 27 Feb '26
27 Feb '26
Vladislav Zavialov pushed to branch wip/int-index/drop-tylit at Glasgow Haskell Compiler / GHC
Commits:
c951fef1 by Cheng Shao at 2026-02-25T20:58:28+00:00
wasm: add /assets endpoint to serve user-specified assets
This patch adds an `/assets` endpoint to the wasm dyld http server, so
that users can also fetch assets from the same host with sensible
default MIME types, without needing a separate http server for assets
that also introduces CORS headaches:
- A `-fghci-browser-assets-dir` driver flag is added to specify the
assets root directory (defaults to `$PWD`)
- The dyld http server fetches `mime-db` on demand and uses it as
source of truth for mime types.
Closes #26951.
- - - - -
dde22f97 by Sylvain Henry at 2026-02-26T13:14:03-05:00
Fix -fcheck-prim-bounds for non constant args (#26958)
Previously we were only checking bounds for constant (literal)
arguments!
I've refactored the code to simplify the generation of out-of-line Cmm
code for the primop composed of some inline code + some call to an
external Cmm function.
- - - - -
bd3eba86 by Vladislav Zavialov at 2026-02-27T05:48:01-05:00
Check for negative type literals in the type checker (#26861)
GHC disallows negative type literals (e.g., -1), as tested by T8306 and
T8412. This check is currently performed in the renamer:
rnHsTyLit tyLit@(HsNumTy x i) = do
when (i < 0) $
addErr $ TcRnNegativeNumTypeLiteral tyLit
However, this check can be bypassed using RequiredTypeArguments
(see the new test case T26861). Prior to this patch, such programs
caused the compiler to hang instead of reporting a proper error.
This patch addresses the issue by adding an equivalent check in
the type checker, namely in tcHsType.
The diff is deliberately minimal to facilitate backporting. A more
comprehensive rework of HsTyLit is planned for a separate commit.
- - - - -
faf14e0c by Vladislav Zavialov at 2026-02-27T05:48:45-05:00
Consistent pretty-printing of HsString, HsIsString, HsStrTy
Factor out a helper to pretty-print string literals, thus fixing newline
handling for overloaded string literals and type literals.
Test cases: T26860ppr T26860ppr_overloaded T26860ppr_tylit
Follow up to ddf1434ff9bb08cfef3c93f23de6b83ec698aa27
- - - - -
a5e26628 by Vladislav Zavialov at 2026-02-27T14:15:28+03:00
Drop HsTyLit in favor of HsLit (#26862, #25121)
This patch is a small step towards unification of HsExpr and HsType,
taking care of literals (HsLit) and type literals (HsTyLit).
Additionally, it improves error messages for unsupported type literals,
such as unboxed or fractional literals (test cases: T26862, T26862_th).
Changes to the AST:
* Use HsLit where HsTyLit was previously used
* Use HsChar where HsCharTy was previously used
* Use HsString where HsStrTy was previously used
* Use HsNatural (NEW) where HsNumTy was previously used
* Use HsDouble (NEW) to represent unsupported fractional type literals
Changes to logic:
* Parse unboxed and fractional type literals (to be rejected later)
* Drop the check for negative literals in the renamer (rnHsTyLit)
in favor of checking in the type checker (tc_hs_lit_ty)
* Check for invalid type literals in TH (repTyLit) and report
unrepresentable literals with ThUnsupportedTyLit
* Allow negative type literals in TH (numTyLit). This is fine as
these will be taken care of at splice time (test case: T8306_th)
- - - - -
63 changed files:
- compiler/GHC/Driver/Config/Interpreter.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/HsToCore/Errors/Ppr.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Interpreter/Init.hs
- compiler/GHC/Runtime/Interpreter/Types.hs
- compiler/GHC/Runtime/Interpreter/Wasm.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/SourceText.hs
- compiler/Language/Haskell/Syntax/Expr.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/Lit.hs
- compiler/Language/Haskell/Syntax/Type.hs
- docs/users_guide/wasm.rst
- libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs
- + testsuite/tests/codeGen/should_fail/T26958.hs
- testsuite/tests/codeGen/should_fail/all.T
- testsuite/tests/ghc-api/annotations-literals/parsed.hs
- + testsuite/tests/parser/should_fail/T26860ppr_overloaded.hs
- + testsuite/tests/parser/should_fail/T26860ppr_overloaded.stderr
- + testsuite/tests/parser/should_fail/T26860ppr_tylit.hs
- + testsuite/tests/parser/should_fail/T26860ppr_tylit.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/th/T26862_th.script
- + testsuite/tests/th/T26862_th.stderr
- + testsuite/tests/th/T8306_th.script
- + testsuite/tests/th/T8306_th.stderr
- + testsuite/tests/th/T8306_th.stdout
- testsuite/tests/th/T8412.stderr
- testsuite/tests/th/all.T
- + testsuite/tests/typecheck/should_fail/T26861.hs
- + testsuite/tests/typecheck/should_fail/T26861.stderr
- + testsuite/tests/typecheck/should_fail/T26862.hs
- + testsuite/tests/typecheck/should_fail/T26862.stderr
- testsuite/tests/typecheck/should_fail/T8306.stderr
- testsuite/tests/typecheck/should_fail/all.T
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13228aaffad76c9e2162464ea7a01a…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13228aaffad76c9e2162464ea7a01a…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] Consistent pretty-printing of HsString, HsIsString, HsStrTy
by Marge Bot (@marge-bot) 27 Feb '26
by Marge Bot (@marge-bot) 27 Feb '26
27 Feb '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
faf14e0c by Vladislav Zavialov at 2026-02-27T05:48:45-05:00
Consistent pretty-printing of HsString, HsIsString, HsStrTy
Factor out a helper to pretty-print string literals, thus fixing newline
handling for overloaded string literals and type literals.
Test cases: T26860ppr T26860ppr_overloaded T26860ppr_tylit
Follow up to ddf1434ff9bb08cfef3c93f23de6b83ec698aa27
- - - - -
7 changed files:
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Type.hs
- + testsuite/tests/parser/should_fail/T26860ppr_overloaded.hs
- + testsuite/tests/parser/should_fail/T26860ppr_overloaded.stderr
- + testsuite/tests/parser/should_fail/T26860ppr_tylit.hs
- + testsuite/tests/parser/should_fail/T26860ppr_tylit.stderr
- testsuite/tests/parser/should_fail/all.T
Changes:
=====================================
compiler/GHC/Hs/Lit.hs
=====================================
@@ -21,7 +21,7 @@ import GHC.Prelude
import {-# SOURCE #-} GHC.Hs.Expr( pprExpr )
-import GHC.Data.FastString (unpackFS)
+import GHC.Data.FastString (FastString, unpackFS)
import GHC.Types.Basic (PprPrec(..), topPrec )
import GHC.Core.Ppr ( {- instance OutputableBndr TyVar -} )
import GHC.Types.SourceText
@@ -209,10 +209,7 @@ Equivalently it's True if
instance IsPass p => Outputable (HsLit (GhcPass p)) where
ppr (HsChar st c) = pprWithSourceText st (pprHsChar c)
ppr (HsCharPrim st c) = pprWithSourceText st (pprPrimChar c)
- ppr (HsString st s) =
- case st of
- NoSourceText -> pprHsString s
- SourceText src -> vcat $ map text $ split '\n' (unpackFS src)
+ ppr (HsString st s) = pprHsStringLit st s
ppr (HsStringPrim st s) = pprWithSourceText st (pprHsBytes s)
ppr (HsInt _ i)
= pprWithSourceText (il_text i) (integer (il_value i))
@@ -233,6 +230,10 @@ instance IsPass p => Outputable (HsLit (GhcPass p)) where
(HsInteger st i _) -> pprWithSourceText st (integer i)
(HsRat f _) -> ppr f
+pprHsStringLit :: SourceText -> FastString -> SDoc
+pprHsStringLit NoSourceText s = pprHsString s
+pprHsStringLit (SourceText src) _ = vcat $ map text $ split '\n' (unpackFS src)
+
-- in debug mode, print the expression that it's resolved to, too
instance OutputableBndrId p
=> Outputable (HsOverLit (GhcPass p)) where
@@ -242,7 +243,7 @@ instance OutputableBndrId p
instance Outputable OverLitVal where
ppr (HsIntegral i) = pprWithSourceText (il_text i) (integer (il_value i))
ppr (HsFractional f) = ppr f
- ppr (HsIsString st s) = pprWithSourceText st (pprHsString s)
+ ppr (HsIsString st s) = pprHsStringLit st s
negateOverLitVal :: OverLitVal -> OverLitVal
negateOverLitVal (HsIntegral i) = HsIntegral (negateIntegralLit i)
=====================================
compiler/GHC/Hs/Type.hs
=====================================
@@ -116,6 +116,7 @@ import GHC.Core.Ppr ( pprOccWithTick)
import GHC.Core.Type
import GHC.Core.Multiplicity( pprArrowWithMultiplicity )
import GHC.Hs.Doc
+import GHC.Hs.Lit (pprHsStringLit)
import GHC.Generics (Generic, Generically(..))
import GHC.Types.Basic
import GHC.Types.SrcLoc
@@ -1346,7 +1347,7 @@ instance (OutputableBndrId pass) => OutputableBndr (GenLocated SrcSpan (FieldOcc
ppr_tylit :: (HsTyLit (GhcPass p)) -> SDoc
ppr_tylit (HsNumTy source i) = pprWithSourceText source (integer i)
-ppr_tylit (HsStrTy source s) = pprWithSourceText source (text (show s))
+ppr_tylit (HsStrTy source s) = pprHsStringLit source s
ppr_tylit (HsCharTy source c) = pprWithSourceText source (text (show c))
pprAnonWildCard :: SDoc
=====================================
testsuite/tests/parser/should_fail/T26860ppr_overloaded.hs
=====================================
@@ -0,0 +1,11 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module T26860ppr_overloaded where
+
+-- Test that the error message containing the string literal is well-formatted.
+-- See also: parser/should_fail/MultilineStringsError
+x :: Int
+x = "first line \
+ \asdf\n\
+ \second line"
+
=====================================
testsuite/tests/parser/should_fail/T26860ppr_overloaded.stderr
=====================================
@@ -0,0 +1,14 @@
+T26860ppr_overloaded.hs:8:5: error: [GHC-39999]
+ • No instance for ‘GHC.Internal.Data.String.IsString Int’
+ arising from the literal ‘"first line \
+ \asdf\n\
+ \second line"’
+ • In the expression:
+ "first line \
+ \asdf\n\
+ \second line"
+ In an equation for ‘x’:
+ x = "first line \
+ \asdf\n\
+ \second line"
+
=====================================
testsuite/tests/parser/should_fail/T26860ppr_tylit.hs
=====================================
@@ -0,0 +1,13 @@
+{-# LANGUAGE DataKinds #-}
+
+module T26860ppr_tylit where
+
+import Data.Kind (Type)
+
+-- Test that the error message containing the string literal is well-formatted.
+-- See also: parser/should_fail/MultilineStringsError
+type X :: Type
+type X = "first line \
+ \asdf\n\
+ \second line"
+
=====================================
testsuite/tests/parser/should_fail/T26860ppr_tylit.stderr
=====================================
@@ -0,0 +1,11 @@
+T26860ppr_tylit.hs:10:10: error: [GHC-83865]
+ • Expected a type,
+ but ‘"first line \
+ \asdf\n\
+ \second line"’ has kind
+ ‘GHC.Internal.Types.Symbol’
+ • In the type ‘"first line \
+ \asdf\n\
+ \second line"’
+ In the type synonym declaration for ‘X’
+
=====================================
testsuite/tests/parser/should_fail/all.T
=====================================
@@ -245,3 +245,5 @@ test('T26418', normal, compile_fail, [''])
test('T12488c', normal, compile_fail, [''])
test('T12488d', normal, compile_fail, [''])
test('T26860ppr', normal, compile_fail, [''])
+test('T26860ppr_overloaded', normal, compile_fail, [''])
+test('T26860ppr_tylit', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/faf14e0c020e9fb66207026110cce2f…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/faf14e0c020e9fb66207026110cce2f…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] Check for negative type literals in the type checker (#26861)
by Marge Bot (@marge-bot) 27 Feb '26
by Marge Bot (@marge-bot) 27 Feb '26
27 Feb '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
bd3eba86 by Vladislav Zavialov at 2026-02-27T05:48:01-05:00
Check for negative type literals in the type checker (#26861)
GHC disallows negative type literals (e.g., -1), as tested by T8306 and
T8412. This check is currently performed in the renamer:
rnHsTyLit tyLit@(HsNumTy x i) = do
when (i < 0) $
addErr $ TcRnNegativeNumTypeLiteral tyLit
However, this check can be bypassed using RequiredTypeArguments
(see the new test case T26861). Prior to this patch, such programs
caused the compiler to hang instead of reporting a proper error.
This patch addresses the issue by adding an equivalent check in
the type checker, namely in tcHsType.
The diff is deliberately minimal to facilitate backporting. A more
comprehensive rework of HsTyLit is planned for a separate commit.
- - - - -
4 changed files:
- compiler/GHC/Tc/Gen/HsType.hs
- + testsuite/tests/typecheck/should_fail/T26861.hs
- + testsuite/tests/typecheck/should_fail/T26861.stderr
- testsuite/tests/typecheck/should_fail/all.T
Changes:
=====================================
compiler/GHC/Tc/Gen/HsType.hs
=====================================
@@ -1264,8 +1264,10 @@ tcHsType _ rn_ty@(HsStarTy _ _) exp_kind
= checkExpKind rn_ty liftedTypeKind liftedTypeKind exp_kind
--------- Literals
-tcHsType _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind
- = do { checkWiredInTyCon naturalTyCon
+tcHsType _ rn_ty@(HsTyLit _ (HsNumTy x n)) exp_kind
+ = do { when (n < 0) $
+ addErr $ TcRnNegativeNumTypeLiteral (HsNumTy x n)
+ ; checkWiredInTyCon naturalTyCon
; checkExpKind rn_ty (mkNumLitTy n) naturalTy exp_kind }
tcHsType _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind
=====================================
testsuite/tests/typecheck/should_fail/T26861.hs
=====================================
@@ -0,0 +1,14 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE NegativeLiterals #-}
+{-# LANGUAGE RequiredTypeArguments #-}
+
+module T26861 where
+
+import Data.Proxy
+import GHC.TypeLits
+
+main :: IO ()
+main = print (natVis (-42))
+
+natVis :: forall a -> KnownNat a => Integer
+natVis n = natVal (Proxy @n)
=====================================
testsuite/tests/typecheck/should_fail/T26861.stderr
=====================================
@@ -0,0 +1,6 @@
+T26861.hs:11:23: error: [GHC-93632]
+ • Illegal literal in type (type literals must not be negative): -42
+ • In the type ‘-42’
+ In the first argument of ‘print’, namely ‘(natVis (-42))’
+ In the expression: print (natVis (-42))
+
=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -752,3 +752,4 @@ test('T23162a', normal, compile_fail, [''])
test('T23162b', normal, compile_fail, [''])
test('T23162c', normal, compile, [''])
test('T23162d', normal, compile, [''])
+test('T26861', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd3eba86180083a3bd1633994b9e6cd…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd3eba86180083a3bd1633994b9e6cd…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc] Pushed new branch wip/int-index/test-diagnostics
by Vladislav Zavialov (@int-index) 27 Feb '26
by Vladislav Zavialov (@int-index) 27 Feb '26
27 Feb '26
Vladislav Zavialov pushed new branch wip/int-index/test-diagnostics at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/test-diagnostics
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T26961] 2 commits: Add Data.RealFloat
by Brandon Chinn (@brandonchinn178) 27 Feb '26
by Brandon Chinn (@brandonchinn178) 27 Feb '26
27 Feb '26
Brandon Chinn pushed to branch wip/T26961 at Glasgow Haskell Compiler / GHC
Commits:
3ccd11ee by Brandon Chinn at 2026-02-26T18:09:54-08:00
Add Data.RealFloat
- - - - -
d77fec68 by Brandon Chinn at 2026-02-26T18:09:54-08:00
Add Infinity/NegInfinity/NaN pattern synonyms (#26961)
- - - - -
4 changed files:
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- + libraries/base/src/Data/RealFloat.hs
- testsuite/tests/interface-stability/base-exports.stdout
Changes:
=====================================
libraries/base/base.cabal.in
=====================================
@@ -111,6 +111,7 @@ Library
, Data.Monoid
, Data.Ord
, Data.Proxy
+ , Data.RealFloat
, Data.STRef
, Data.STRef.Strict
, Data.String
=====================================
libraries/base/changelog.md
=====================================
@@ -9,6 +9,8 @@
* Add `Data.List.NonEmpty.mapMaybe`. ([CLC proposal #337](https://github.com/haskell/core-libraries-committee/issues/337))
* Fix issues with toRational for types capable to represent infinite and not-a-number values ([CLC proposal #338](https://github.com/haskell/core-libraries-committee/issues/338))
* Ensure that `rationalToFloat` and `rationalToDouble` always inline in the end. ([CLC proposal #356](https://github.com/haskell/core-libraries-committee/issues/356))
+ * Add new `Data.RealFloat` module re-exporting `RealFloat` from `GHC.Float`
+ * Add `Infinity`, `NegInfinity`, and `NaN` pattern synonyms to `Data.RealFloat`
* Modify the implementation of `Data.List.sortOn` to use `(>)` instead of `compare`. ([CLC proposal #332](https://github.com/haskell/core-libraries-committee/issues/332))
* Add `thenA` and `thenM`. ([CLC proposal #351](https://github.com/haskell/core-libraries-committee/issues/351))
* Fix bug where `naturalAndNot` was incorrectly truncating results ([CLC proposal #350](github.com/haskell/core-libraries-committee/issues/350))
=====================================
libraries/base/src/Data/RealFloat.hs
=====================================
@@ -0,0 +1,42 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE Safe #-}
+{-# LANGUAGE ViewPatterns #-}
+
+-- |
+--
+-- Module : Data.RealFloat
+-- Copyright : (c) The University of Glasgow 2026
+-- License : BSD-style (see the file libraries/base/LICENSE)
+--
+-- Maintainer : libraries(a)haskell.org
+-- Stability : stable
+-- Portability : portable
+--
+
+module Data.RealFloat (
+ RealFloat (..),
+
+ -- * Infinity + NaN
+ pattern Infinity,
+ pattern NegInfinity,
+ pattern NaN,
+) where
+
+import GHC.Internal.Data.Bool
+import GHC.Internal.Data.Ord
+import GHC.Internal.Float
+import GHC.Internal.Real
+
+pattern Infinity :: (RealFloat a) => a
+pattern Infinity <- ((\x -> isInfinite x && x > 0) -> True) where Infinity = 1/0
+
+-- | Negative infinity
+--
+-- Provided for convenience. Could also use the following instead:
+-- * Pattern matching: @(negate -> Infinity)@
+-- * Expressions: @-Infinity@
+pattern NegInfinity :: (RealFloat a) => a
+pattern NegInfinity <- ((\x -> isInfinite x && x < 0) -> True) where NegInfinity = -1/0
+
+pattern NaN :: (RealFloat a) => a
+pattern NaN <- (isNaN -> True) where NaN = 0/0
=====================================
testsuite/tests/interface-stability/base-exports.stdout
=====================================
@@ -1597,6 +1597,29 @@ module Data.Ratio where
denominator :: forall a. Ratio a -> a
numerator :: forall a. Ratio a -> a
+module Data.RealFloat where
+ -- Safety: Safe
+ pattern Infinity :: forall a. RealFloat a => a
+ pattern NaN :: forall a. RealFloat a => a
+ pattern NegInfinity :: forall a. RealFloat a => a
+ type RealFloat :: * -> Constraint
+ class (GHC.Internal.Real.RealFrac a, GHC.Internal.Float.Floating a) => RealFloat a where
+ floatRadix :: a -> GHC.Internal.Bignum.Integer.Integer
+ floatDigits :: a -> GHC.Internal.Types.Int
+ floatRange :: a -> (GHC.Internal.Types.Int, GHC.Internal.Types.Int)
+ decodeFloat :: a -> (GHC.Internal.Bignum.Integer.Integer, GHC.Internal.Types.Int)
+ encodeFloat :: GHC.Internal.Bignum.Integer.Integer -> GHC.Internal.Types.Int -> a
+ exponent :: a -> GHC.Internal.Types.Int
+ significand :: a -> a
+ scaleFloat :: GHC.Internal.Types.Int -> a -> a
+ isNaN :: a -> GHC.Internal.Types.Bool
+ isInfinite :: a -> GHC.Internal.Types.Bool
+ isDenormalized :: a -> GHC.Internal.Types.Bool
+ isNegativeZero :: a -> GHC.Internal.Types.Bool
+ isIEEE :: a -> GHC.Internal.Types.Bool
+ atan2 :: a -> a -> a
+ {-# MINIMAL floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE #-}
+
module Data.STRef where
-- Safety: Safe
type role STRef nominal representational
@@ -11952,6 +11975,8 @@ instance forall k (f :: k -> *) (a :: k). GHC.Internal.Enum.Enum (f a) => GHC.In
instance forall k (f :: k -> *) (a :: k). GHC.Internal.Enum.Enum (f a) => GHC.Internal.Enum.Enum (GHC.Internal.Data.Monoid.Ap f a) -- Defined in ‘GHC.Internal.Data.Monoid’
instance forall a. (GHC.Internal.Enum.Enum a, GHC.Internal.Enum.Bounded a, GHC.Internal.Classes.Eq a) => GHC.Internal.Enum.Enum (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
instance forall a. GHC.Internal.Real.Integral a => GHC.Internal.Enum.Enum (GHC.Internal.Real.Ratio a) -- Defined in ‘GHC.Internal.Real’
+instance GHC.Internal.Enum.Enum GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Enum.Enum GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance forall a. GHC.Internal.Enum.Enum a => GHC.Internal.Enum.Enum (Data.Semigroup.First a) -- Defined in ‘Data.Semigroup’
instance forall a. GHC.Internal.Enum.Enum a => GHC.Internal.Enum.Enum (Data.Semigroup.Last a) -- Defined in ‘Data.Semigroup’
instance forall a. GHC.Internal.Enum.Enum a => GHC.Internal.Enum.Enum (Data.Semigroup.Max a) -- Defined in ‘Data.Semigroup’
@@ -11991,8 +12016,6 @@ instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUSeconds -- Define
instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Enum.Enum GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Enum.Enum GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.ByteOrder’
-instance GHC.Internal.Enum.Enum GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
-instance GHC.Internal.Enum.Enum GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Enum.Enum GHC.Internal.Generics.Associativity -- Defined in ‘GHC.Internal.Generics’
instance GHC.Internal.Enum.Enum GHC.Internal.Generics.DecidedStrictness -- Defined in ‘GHC.Internal.Generics’
instance GHC.Internal.Enum.Enum GHC.Internal.Generics.SourceStrictness -- Defined in ‘GHC.Internal.Generics’
@@ -12039,18 +12062,18 @@ instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Flo
instance forall a b. GHC.Internal.Float.Floating a => GHC.Internal.Float.Floating (Data.Functor.Contravariant.Op a b) -- Defined in ‘Data.Functor.Contravariant’
instance forall a. GHC.Internal.Float.Floating a => GHC.Internal.Float.Floating (GHC.Internal.Data.Functor.Identity.Identity a) -- Defined in ‘GHC.Internal.Data.Functor.Identity’
instance forall a. GHC.Internal.Float.Floating a => GHC.Internal.Float.Floating (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
-instance GHC.Internal.Float.Floating GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
-instance GHC.Internal.Float.Floating GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Float.Floating GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Float.Floating GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Float.Floating GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
+instance GHC.Internal.Float.Floating GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance forall a k (b :: k). GHC.Internal.Float.RealFloat a => GHC.Internal.Float.RealFloat (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’
instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Float.RealFloat (f (g a)) => GHC.Internal.Float.RealFloat (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’
instance forall a. GHC.Internal.Float.RealFloat a => GHC.Internal.Float.RealFloat (GHC.Internal.Data.Functor.Identity.Identity a) -- Defined in ‘GHC.Internal.Data.Functor.Identity’
instance forall a. GHC.Internal.Float.RealFloat a => GHC.Internal.Float.RealFloat (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
-instance GHC.Internal.Float.RealFloat GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
-instance GHC.Internal.Float.RealFloat GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Float.RealFloat GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Float.RealFloat GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Float.RealFloat GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
+instance GHC.Internal.Float.RealFloat GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance forall a k (b :: k). GHC.Internal.Foreign.Storable.Storable a => GHC.Internal.Foreign.Storable.Storable (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’
instance forall a. GHC.Internal.Foreign.Storable.Storable a => GHC.Internal.Foreign.Storable.Storable (Data.Complex.Complex a) -- Defined in ‘Data.Complex’
instance forall a. GHC.Internal.Foreign.Storable.Storable a => GHC.Internal.Foreign.Storable.Storable (GHC.Internal.Data.Functor.Identity.Identity a) -- Defined in ‘GHC.Internal.Data.Functor.Identity’
@@ -12379,6 +12402,8 @@ instance forall a. GHC.Internal.Num.Num a => GHC.Internal.Num.Num (GHC.Internal.
instance forall (f :: * -> *) a. (GHC.Internal.Base.Applicative f, GHC.Internal.Num.Num a) => GHC.Internal.Num.Num (GHC.Internal.Data.Monoid.Ap f a) -- Defined in ‘GHC.Internal.Data.Monoid’
instance forall a. GHC.Internal.Num.Num a => GHC.Internal.Num.Num (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
instance forall a. GHC.Internal.Real.Integral a => GHC.Internal.Num.Num (GHC.Internal.Real.Ratio a) -- Defined in ‘GHC.Internal.Real’
+instance GHC.Internal.Num.Num GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Num.Num GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance forall a. GHC.Internal.Num.Num a => GHC.Internal.Num.Num (Data.Semigroup.Max a) -- Defined in ‘Data.Semigroup’
instance forall a. GHC.Internal.Num.Num a => GHC.Internal.Num.Num (Data.Semigroup.Min a) -- Defined in ‘Data.Semigroup’
instance GHC.Internal.Num.Num GHC.Internal.Word.Word16 -- Defined in ‘GHC.Internal.Word’
@@ -12413,8 +12438,6 @@ instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CULong -- Defined in
instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Num.Num GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’
-instance GHC.Internal.Num.Num GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
-instance GHC.Internal.Num.Num GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Num.Num GHC.Internal.Types.Int -- Defined in ‘GHC.Internal.Num’
instance GHC.Internal.Num.Num GHC.Internal.Bignum.Integer.Integer -- Defined in ‘GHC.Internal.Num’
instance GHC.Internal.Num.Num GHC.Internal.Bignum.Natural.Natural -- Defined in ‘GHC.Internal.Num’
@@ -12556,10 +12579,10 @@ instance forall a b. GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractio
instance forall a. GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (GHC.Internal.Data.Functor.Identity.Identity a) -- Defined in ‘GHC.Internal.Data.Functor.Identity’
instance forall a. GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
instance forall a. GHC.Internal.Real.Integral a => GHC.Internal.Real.Fractional (GHC.Internal.Real.Ratio a) -- Defined in ‘GHC.Internal.Real’
-instance GHC.Internal.Real.Fractional GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
-instance GHC.Internal.Real.Fractional GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Real.Fractional GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Real.Fractional GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Real.Fractional GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
+instance GHC.Internal.Real.Fractional GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance forall a k (b :: k). GHC.Internal.Real.Integral a => GHC.Internal.Real.Integral (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’
instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.Integral (f (g a)) => GHC.Internal.Real.Integral (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’
instance forall a. GHC.Internal.Real.Integral a => GHC.Internal.Real.Integral (GHC.Internal.Data.Functor.Identity.Identity a) -- Defined in ‘GHC.Internal.Data.Functor.Identity’
@@ -12611,6 +12634,8 @@ instance GHC.Internal.Real.Real GHC.Internal.Bignum.Integer.Integer -- Defined i
instance GHC.Internal.Real.Real GHC.Internal.Bignum.Natural.Natural -- Defined in ‘GHC.Internal.Real’
instance forall a. GHC.Internal.Real.Integral a => GHC.Internal.Real.Real (GHC.Internal.Real.Ratio a) -- Defined in ‘GHC.Internal.Real’
instance GHC.Internal.Real.Real GHC.Internal.Types.Word -- Defined in ‘GHC.Internal.Real’
+instance GHC.Internal.Real.Real GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Real.Real GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Real.Real GHC.Internal.Word.Word16 -- Defined in ‘GHC.Internal.Word’
instance GHC.Internal.Real.Real GHC.Internal.Word.Word32 -- Defined in ‘GHC.Internal.Word’
instance GHC.Internal.Real.Real GHC.Internal.Word.Word64 -- Defined in ‘GHC.Internal.Word’
@@ -12643,18 +12668,16 @@ instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CULong -- Defined i
instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Real.Real GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’
-instance GHC.Internal.Real.Real GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
-instance GHC.Internal.Real.Real GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance forall a k (b :: k). GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’
instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.RealFrac (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’
instance forall k1 k2 (f :: k1 -> *) (g :: k2 -> k1) (a :: k2). GHC.Internal.Real.RealFrac (f (g a)) => GHC.Internal.Real.RealFrac (Data.Functor.Compose.Compose f g a) -- Defined in ‘Data.Functor.Compose’
instance forall a. GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Functor.Identity.Identity a) -- Defined in ‘GHC.Internal.Data.Functor.Identity’
instance forall a. GHC.Internal.Real.RealFrac a => GHC.Internal.Real.RealFrac (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
instance forall a. GHC.Internal.Real.Integral a => GHC.Internal.Real.RealFrac (GHC.Internal.Real.Ratio a) -- Defined in ‘GHC.Internal.Real’
-instance GHC.Internal.Real.RealFrac GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
-instance GHC.Internal.Real.RealFrac GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance GHC.Internal.Real.RealFrac GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
instance GHC.Internal.Real.RealFrac GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Real.RealFrac GHC.Internal.Foreign.C.Types.CDouble -- Defined in ‘GHC.Internal.Foreign.C.Types’
+instance GHC.Internal.Real.RealFrac GHC.Internal.Foreign.C.Types.CFloat -- Defined in ‘GHC.Internal.Foreign.C.Types’
instance forall k a (b :: k). GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’
instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Functor.ZipList.ZipList a) -- Defined in ‘GHC.Internal.Functor.ZipList’
instance GHC.Internal.Show.Show GHC.Internal.Conc.Sync.BlockReason -- Defined in ‘GHC.Internal.Conc.Sync’
@@ -12768,6 +12791,8 @@ instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Inter
instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Data.Ord.Down a) -- Defined in ‘GHC.Internal.Data.Ord’
instance GHC.Internal.Show.Show GHC.Internal.Real.FractionalExponentBase -- Defined in ‘GHC.Internal.Real’
instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Internal.Real.Ratio a) -- Defined in ‘GHC.Internal.Real’
+instance GHC.Internal.Show.Show GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
+instance GHC.Internal.Show.Show GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance forall a b. (GHC.Internal.Show.Show a, GHC.Internal.Show.Show b) => GHC.Internal.Show.Show (Data.Semigroup.Arg a b) -- Defined in ‘Data.Semigroup’
instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Semigroup.First a) -- Defined in ‘Data.Semigroup’
instance forall a. GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.Semigroup.Last a) -- Defined in ‘Data.Semigroup’
@@ -12823,8 +12848,6 @@ instance GHC.Internal.Show.Show ghc-internal-9.1500.0:GHC.Internal.Event.Manager
instance GHC.Internal.Show.Show ghc-internal-9.1500.0:GHC.Internal.Event.Manager.State -- Defined in ‘ghc-internal-9.1500.0:GHC.Internal.Event.Manager’
instance GHC.Internal.Show.Show ghc-internal-9.1500.0:GHC.Internal.Event.TimerManager.State -- Defined in ‘ghc-internal-9.1500.0:GHC.Internal.Event.TimerManager’
instance GHC.Internal.Show.Show GHC.Internal.Fingerprint.Type.Fingerprint -- Defined in ‘GHC.Internal.Fingerprint.Type’
-instance GHC.Internal.Show.Show GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Float’
-instance GHC.Internal.Show.Show GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Float’
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Show.Show (f p), GHC.Internal.Show.Show (g p)) => GHC.Internal.Show.Show ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Show.Show (f p), GHC.Internal.Show.Show (g p)) => GHC.Internal.Show.Show ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’
instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Internal.Show.Show (f (g p)) => GHC.Internal.Show.Show ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fab8136ede6e3bb48e53aef94307ff…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fab8136ede6e3bb48e53aef94307ff…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
27 Feb '26
Jaro Reinders pushed new branch wip/reduce-type-in-stg at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/reduce-type-in-stg
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/ani/kill-SrcCodeOrigin] Improvements in ErrCtxt
by Simon Peyton Jones (@simonpj) 27 Feb '26
by Simon Peyton Jones (@simonpj) 27 Feb '26
27 Feb '26
Simon Peyton Jones pushed to branch wip/ani/kill-SrcCodeOrigin at Glasgow Haskell Compiler / GHC
Commits:
5cca9b8d by Simon Peyton Jones at 2026-02-27T00:44:47+00:00
Improvements in ErrCtxt
- - - - -
24 changed files:
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Match.hs-boot
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Class.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/Origin.hs-boot
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
Changes:
=====================================
compiler/GHC/Tc/Deriv.hs
=====================================
@@ -21,6 +21,7 @@ import GHC.Driver.Session
import GHC.Tc.Errors.Types
import GHC.Tc.Instance.Family
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt(..) )
import GHC.Tc.Deriv.Infer
import GHC.Tc.Deriv.Utils
import GHC.Tc.Deriv.Generate
@@ -695,7 +696,7 @@ deriveStandalone (L loc (DerivDecl (warn, _) deriv_ty mb_lderiv_strat overlap_mo
= setSrcSpanA loc $
addErrCtxt (StandaloneDerivCtxt deriv_ty) $
do { traceTc "Standalone deriving decl for" (ppr deriv_ty)
- ; let ctxt = GHC.Tc.Types.Origin.InstDeclCtxt True
+ ; let ctxt = GHC.Tc.Types.ErrCtxt.InstDeclCtxt True
; traceTc "Deriving strategy (standalone deriving)" $
vcat [ppr mb_lderiv_strat, ppr deriv_ty]
; (mb_lderiv_strat, via_tvs) <- tcDerivStrategy mb_lderiv_strat
=====================================
compiler/GHC/Tc/Deriv/Utils.hs
=====================================
@@ -37,6 +37,7 @@ import GHC.Tc.Deriv.Generics
import GHC.Tc.Errors.Types
import GHC.Tc.Types.Constraint (WantedConstraints, mkNonCanonical)
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt( InstDeclCtxt, DerivClauseCtxt ) )
import GHC.Tc.Utils.Monad
import GHC.Tc.Utils.TcType
import GHC.Tc.Utils.Unify (tcSubTypeSigma)
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -33,6 +33,7 @@ import GHC.Tc.Zonk.Type
import GHC.Tc.Utils.TcType
import GHC.Tc.Zonk.TcType
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( redundantConstraintsSpan )
import GHC.Tc.Types.Evidence
import GHC.Tc.Instance.Family
import GHC.Tc.Utils.Instantiate
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -7703,11 +7703,17 @@ pprErrCtxtMsg = \case
make_lines_msg [last] = ppr last <> dot
make_lines_msg [l1,l2] = l1 $$ text "and" <+> l2 <> dot
make_lines_msg (l:ls) = l <> comma $$ make_lines_msg ls
+
PatSigErrCtxt sig_ty res_ty ->
vcat [ hang (text "When checking that the pattern signature:")
4 (ppr sig_ty)
- , nest 2 (hang (text "fits the type of its context:")
- 2 (ppr res_ty)) ]
+ , nest 2 (hang (text "fits the type of its context:") 2 pp_res_ty) ]
+ where
+ -- Zonking will have turned Infer into Check
+ pp_res_ty = case res_ty of
+ Check ty -> ppr ty
+ Infer ir -> text "OOPS" <+> ppr ir
+
PatCtxt pat ->
hang (text "In the pattern:") 2 (ppr pat)
PatSynDeclCtxt name ->
=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -184,7 +184,7 @@ import GHC.Tc.Types.Constraint
import GHC.Tc.Types.Evidence (EvBindsVar)
import GHC.Tc.Types.ErrCtxt
import GHC.Tc.Types.Origin ( CtOrigin (ProvCtxtOrigin), SkolemInfoAnon (SigSkol)
- , UserTypeCtxt (PatSynCtxt), TyVarBndrs, TypedThing
+ , TyVarBndrs, TypedThing
, FixedRuntimeRepOrigin(..), InstanceWhat )
import GHC.Tc.Types.CtLoc( CtLoc, ctLocOrigin, SubGoalDepth )
import GHC.Tc.Types.Rank (Rank)
=====================================
compiler/GHC/Tc/Gen/Bind.hs
=====================================
@@ -35,6 +35,7 @@ import GHC.Tc.Gen.Sig
import GHC.Tc.Utils.Concrete ( hasFixedRuntimeRep_syntactic )
import GHC.Tc.Utils.Monad
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Tc.Utils.Env
import GHC.Tc.Utils.Unify
import GHC.Tc.Solver
=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -41,6 +41,7 @@ import GHC.Tc.Errors.Types
import GHC.Tc.Solver ( InferMode(..), simplifyInfer )
import GHC.Tc.Utils.Env
import GHC.Tc.Utils.TcMType
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Tc.Types.Origin
import GHC.Tc.Types.Constraint( WantedConstraints )
import GHC.Tc.Utils.TcType as TcType
=====================================
compiler/GHC/Tc/Gen/Match.hs
=====================================
@@ -52,6 +52,7 @@ import GHC.Tc.Gen.Bind
import GHC.Tc.Utils.Concrete ( hasFixedRuntimeRep_syntactic )
import GHC.Tc.Utils.Unify
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt( GenSigCtxt ), pprUserTypeCtxt )
import GHC.Tc.Types.Evidence
import GHC.Rename.Env ( irrefutableConLikeTc )
=====================================
compiler/GHC/Tc/Gen/Match.hs-boot
=====================================
@@ -2,7 +2,7 @@ module GHC.Tc.Gen.Match where
import GHC.Hs ( GRHSs, MatchGroup, LHsExpr, Mult )
import GHC.Tc.Utils.TcType( ExpSigmaType, ExpRhoType, ExpPatType )
import GHC.Tc.Types ( TcM )
-import GHC.Tc.Types.Origin ( UserTypeCtxt )
+import GHC.Tc.Types.ErrCtxt ( UserTypeCtxt )
import GHC.Tc.Types.Evidence ( HsWrapper )
import GHC.Types.Name ( Name )
import GHC.Hs.Extension ( GhcRn, GhcTc )
=====================================
compiler/GHC/Tc/Gen/Pat.hs
=====================================
@@ -1021,8 +1021,7 @@ tcPatSig in_pat_bind sig res_ty
; case NE.nonEmpty sig_tvs of
Nothing -> do {
-- Just do the subsumption check and return
- msg <- mk_msg res_ty sig_ty
- ; wrap <- addErrCtxtM msg $
+ ; wrap <- addErrCtxtM (PatSigErrCtxt sig_ty res_ty) $
tcSubTypePat PatSigOrigin PatSigCtxt res_ty sig_ty
; return (sig_ty, [], sig_wcs, wrap)
}
@@ -1036,17 +1035,12 @@ tcPatSig in_pat_bind sig res_ty
(addErr (TcRnCannotBindScopedTyVarInPatSig sig_tvs_ne))
-- Now do a subsumption check of the pattern signature against res_ty
- msg <- mk_msg res_ty sig_ty
- wrap <- addErrCtxtM msg $
+ wrap <- addErrCtxtM (PatSigErrCtxt sig_ty res_ty) $
tcSubTypePat PatSigOrigin PatSigCtxt res_ty sig_ty
-- Phew!
return (sig_ty, sig_tvs, sig_wcs, wrap)
}
- where
- mk_msg res_ty sig_ty
- = do { res_ty <- readExpType res_ty -- should be filled in by now
- ; return $ PatSigErrCtxt sig_ty res_ty }
{- *********************************************************************
* *
=====================================
compiler/GHC/Tc/Gen/Sig.hs
=====================================
@@ -50,6 +50,7 @@ import GHC.Tc.Utils.Instantiate( topInstantiate, tcInstTypeBndrs )
import GHC.Tc.Utils.Env
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Tc.Types.Evidence
import GHC.Tc.Types.Constraint
=====================================
compiler/GHC/Tc/Module.hs
=====================================
@@ -65,6 +65,7 @@ import GHC.Tc.Utils.Monad
import GHC.Tc.Gen.Export
import GHC.Tc.Types.Evidence
import GHC.Tc.Types.Constraint
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Tc.Types.Origin
import GHC.Tc.Instance.Family
import GHC.Tc.Gen.Annotation
=====================================
compiler/GHC/Tc/Solver/Solve.hs
=====================================
@@ -23,6 +23,7 @@ import GHC.Tc.Types.Evidence
import GHC.Tc.Types.CtLoc( ctLocEnv, ctLocOrigin, setCtLocOrigin )
import GHC.Tc.Types
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt(..), reportRedundantConstraints )
import GHC.Tc.Types.Constraint
import GHC.Tc.Types.CtLoc( mkGivenLoc )
import GHC.Tc.Solver.InertSet
=====================================
compiler/GHC/Tc/TyCl.hs
=====================================
@@ -58,6 +58,7 @@ import GHC.Tc.Instance.Family
import GHC.Tc.Types.ErrCtxt ( TyConInstFlavour(..) )
import GHC.Tc.Types.LclEnv
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Builtin.Types ( oneDataConTy, unitTy, makeRecoveryTyCon, manyDataConTy )
=====================================
compiler/GHC/Tc/TyCl/Class.hs
=====================================
@@ -38,6 +38,7 @@ import GHC.Tc.Utils.Unify
import GHC.Tc.Utils.Instantiate( newFamInst, tcSuperSkolTyVars )
import GHC.Tc.Gen.HsType
import GHC.Tc.Utils.TcMType
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Tc.Types.Origin
import GHC.Tc.Utils.TcType
import GHC.Tc.Utils.Monad
=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -38,6 +38,7 @@ import GHC.Tc.Utils.TcMType
import GHC.Tc.Utils.TcType
import GHC.Tc.Types.Constraint
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( ReportRedundantConstraints(..) )
import GHC.Tc.TyCl.Build
import GHC.Tc.Utils.Instantiate
import GHC.Tc.Instance.Class( AssocInstInfo(..), isNotAssociated )
=====================================
compiler/GHC/Tc/TyCl/PatSyn.hs
=====================================
@@ -32,6 +32,7 @@ import GHC.Tc.Utils.Unify
import GHC.Tc.Utils.TcType
import GHC.Tc.Types.Evidence
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt(..) )
import GHC.Tc.TyCl.Build
import GHC.Core.Multiplicity
=====================================
compiler/GHC/Tc/Types/BasicTypes.hs
=====================================
@@ -22,7 +22,7 @@ module GHC.Tc.Types.BasicTypes (
import GHC.Prelude
-import GHC.Tc.Types.Origin( UserTypeCtxt )
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt )
import GHC.Tc.Utils.TcType
import GHC.Types.Id
=====================================
compiler/GHC/Tc/Types/Constraint.hs
=====================================
@@ -120,6 +120,7 @@ import GHC.Types.Var
import GHC.Tc.Utils.TcType
import GHC.Tc.Types.Evidence
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt
import GHC.Tc.Types.CtLoc
import GHC.Builtin.Names
=====================================
compiler/GHC/Tc/Types/ErrCtxt.hs
=====================================
@@ -4,6 +4,11 @@ module GHC.Tc.Types.ErrCtxt
( ErrCtxt (..), ErrCtxtMsg(..), CodeSrcFlag (..)
, UserSigType(..), FunAppCtxtFunArg(..)
, TyConInstFlavour(..)
+
+ -- * UserTypeCtxt
+ , UserTypeCtxt(..), pprUserTypeCtxt, isSigMaybe
+ , ReportRedundantConstraints(..), reportRedundantConstraints
+ , redundantConstraintsSpan,
)
where
@@ -16,12 +21,12 @@ import GHC.Hs.Extension
import GHC.Parser.Annotation ( LocatedN, SrcSpanAnnA )
import GHC.Tc.Errors.Types.PromotionErr ( TermLevelUseCtxt )
-import {-# SOURCE #-} GHC.Tc.Types.Origin ( CtOrigin, UserTypeCtxt )
-import {-# SOURCE #-} GHC.Tc.Utils.TcType ( TcType, TcTyCon )
+import {-# SOURCE #-} GHC.Tc.Types.Origin ( CtOrigin )
+import GHC.Tc.Utils.TcType ( TcType, TcTyCon, ExpType )
import GHC.Types.Basic ( TyConFlavour )
import GHC.Types.Name ( Name )
-import GHC.Types.SrcLoc ( SrcSpan )
+import GHC.Types.SrcLoc ( SrcSpan, noSrcSpan )
import GHC.Types.Var ( Id, TyCoVar )
import GHC.Unit.Types ( Module, InstantiatedModule )
@@ -35,7 +40,7 @@ import GHC.Core.TyCo.Rep ( Type, ThetaType, PredType )
import {-# SOURCE #-} GHC.Unit.State ( UnitState ) -- Break the module graph cycle for accesing ErrCtxtMsg in GHC.Hs.Expr
import GHC.Data.FastString ( FastString )
-import GHC.Utils.Outputable ( Outputable(..) )
+import GHC.Utils.Outputable
import Language.Haskell.Syntax
import Language.Haskell.Syntax.Basic ( FieldLabelString(..) )
@@ -43,6 +48,156 @@ import GHC.Boot.TH.Syntax qualified as TH
import qualified Data.List.NonEmpty as NE
+{- *********************************************************************
+* *
+ UserTypeCtxt
+* *
+********************************************************************* -}
+
+-------------------------------------
+-- | UserTypeCtxt describes the origin of the polymorphic type
+-- in the places where we need an expression to have that type
+data UserTypeCtxt
+ = FunSigCtxt -- Function type signature, when checking the type
+ -- Also used for types in SPECIALISE pragmas
+ Name -- Name of the function
+ ReportRedundantConstraints
+ -- See Note [Tracking needed EvIds] in GHC.Tc.Solver
+ -- This field is usually 'WantRCC', but 'NoRCC' for
+ -- * Record selectors (not important here)
+ -- * Class and instance methods. Here the code may legitimately
+ -- be more polymorphic than the signature generated from the
+ -- class declaration
+ -- * Functions whose type signature has hidden the constraints
+ -- behind a type synonym. E.g.
+ -- type Foo = forall a. Eq a => a -> a
+ -- id :: Foo
+ -- id x = x
+ -- Here we can't give a good location for the redundant constraints
+ -- (see lhsSigWcTypeContextSpan), so we don't report redundant
+ -- constraints at all. It's not clear that this a good choice;
+ -- perhaps we should report, just with a less informative SrcSpan.
+ -- c.f. #16154
+
+ | InfSigCtxt Name -- Inferred type for function
+ | ExprSigCtxt -- Expression type signature
+ ReportRedundantConstraints
+ | KindSigCtxt -- Kind signature
+ | StandaloneKindSigCtxt -- Standalone kind signature
+ Name -- Name of the type/class
+ | TypeAppCtxt -- Visible type application
+ | ConArgCtxt Name -- Data constructor argument
+ | TySynCtxt Name -- RHS of a type synonym decl
+ | PatSynCtxt Name -- Type sig for a pattern synonym
+ | PatSigCtxt -- Type sig in pattern
+ -- eg f (x::t) = ...
+ -- or (x::t, y) = e
+ | ForSigCtxt Name -- Foreign import or export signature
+ | DefaultDeclCtxt -- Class or types in a default declaration
+ | InstDeclCtxt Bool -- An instance declaration
+ -- True: stand-alone deriving
+ -- False: vanilla instance declaration
+ | SpecInstCtxt -- SPECIALISE instance pragma
+ | GenSigCtxt -- Higher-rank or impredicative situations
+ -- e.g. (f e) where f has a higher-rank type
+ -- We might want to elaborate this
+ | GhciCtxt Bool -- GHCi command :kind <type>
+ -- The Bool indicates if we are checking the outermost
+ -- type application.
+ -- See Note [Unsaturated type synonyms in GHCi] in
+ -- GHC.Tc.Validity.
+
+ | ClassSCCtxt Name -- Superclasses of a class
+ | SigmaCtxt -- Theta part of a normal for-all type
+ -- f :: <S> => a -> a
+ | DataTyCtxt Name -- The "stupid theta" part of a data decl
+ -- data <S> => T a = MkT a
+ | DerivClauseCtxt -- A 'deriving' clause
+ | TyVarBndrKindCtxt Name -- The kind of a type variable being bound
+ | RuleBndrTypeCtxt Name -- The type of a term variable being bound in a RULE
+ -- or SPECIALISE pragma
+ -- RULE "foo" forall (x :: a -> a). f (Just x) = ...
+ | DataKindCtxt Name -- The kind of a data/newtype (instance)
+ | TySynKindCtxt Name -- The kind of the RHS of a type synonym
+ | TyFamResKindCtxt Name -- The result kind of a type family
+ deriving( Eq ) -- Just for checkSkolInfoAnon
+
+-- | Report Redundant Constraints.
+data ReportRedundantConstraints
+ = NoRRC -- ^ Don't report redundant constraints
+
+ | WantRRC SrcSpan -- ^ Report redundant constraints
+ -- The SrcSpan is for the constraints
+ -- E.g. f :: (Eq a, Ord b) => blah
+ -- The span is for the (Eq a, Ord b)
+ -- We need to record the span here because we have
+ -- long since discarded the HsType in favour of a Type
+
+ deriving( Eq ) -- Just for checkSkolInfoAnon
+
+reportRedundantConstraints :: ReportRedundantConstraints -> Bool
+reportRedundantConstraints NoRRC = False
+reportRedundantConstraints (WantRRC {}) = True
+
+redundantConstraintsSpan :: UserTypeCtxt -> SrcSpan
+redundantConstraintsSpan (FunSigCtxt _ (WantRRC span)) = span
+redundantConstraintsSpan (ExprSigCtxt (WantRRC span)) = span
+redundantConstraintsSpan _ = noSrcSpan
+
+{-
+-- Notes re TySynCtxt
+-- We allow type synonyms that aren't types; e.g. type List = []
+--
+-- If the RHS mentions tyvars that aren't in scope, we'll
+-- quantify over them:
+-- e.g. type T = a->a
+-- will become type T = forall a. a->a
+--
+-- With gla-exts that's right, but for H98 we should complain.
+-}
+
+
+pprUserTypeCtxt :: UserTypeCtxt -> SDoc
+pprUserTypeCtxt (FunSigCtxt n _) = text "the type signature for" <+> quotes (ppr n)
+pprUserTypeCtxt (InfSigCtxt n) = text "the inferred type for" <+> quotes (ppr n)
+pprUserTypeCtxt (ExprSigCtxt _) = text "an expression type signature"
+pprUserTypeCtxt KindSigCtxt = text "a kind signature"
+pprUserTypeCtxt (StandaloneKindSigCtxt n) = text "a standalone kind signature for" <+> quotes (ppr n)
+pprUserTypeCtxt TypeAppCtxt = text "a type argument"
+pprUserTypeCtxt (ConArgCtxt c) = text "the type of the constructor" <+> quotes (ppr c)
+pprUserTypeCtxt (TySynCtxt c) = text "the RHS of the type synonym" <+> quotes (ppr c)
+pprUserTypeCtxt PatSigCtxt = text "a pattern type signature"
+pprUserTypeCtxt (ForSigCtxt n) = text "the foreign declaration for" <+> quotes (ppr n)
+pprUserTypeCtxt DefaultDeclCtxt = text "a `default' declaration"
+pprUserTypeCtxt (InstDeclCtxt False) = text "an instance declaration"
+pprUserTypeCtxt (InstDeclCtxt True) = text "a stand-alone deriving instance declaration"
+pprUserTypeCtxt SpecInstCtxt = text "a SPECIALISE instance pragma"
+pprUserTypeCtxt GenSigCtxt = text "a type expected by the context"
+pprUserTypeCtxt (GhciCtxt {}) = text "a type in a GHCi command"
+pprUserTypeCtxt (ClassSCCtxt c) = text "the super-classes of class" <+> quotes (ppr c)
+pprUserTypeCtxt SigmaCtxt = text "the context of a polymorphic type"
+pprUserTypeCtxt (DataTyCtxt tc) = text "the context of the data type declaration for" <+> quotes (ppr tc)
+pprUserTypeCtxt (PatSynCtxt n) = text "the signature for pattern synonym" <+> quotes (ppr n)
+pprUserTypeCtxt (DerivClauseCtxt) = text "a `deriving' clause"
+pprUserTypeCtxt (TyVarBndrKindCtxt n) = text "the kind annotation on the type variable" <+> quotes (ppr n)
+pprUserTypeCtxt (RuleBndrTypeCtxt n) = text "the type signature for" <+> quotes (ppr n)
+pprUserTypeCtxt (DataKindCtxt n) = text "the kind annotation on the declaration for" <+> quotes (ppr n)
+pprUserTypeCtxt (TySynKindCtxt n) = text "the kind annotation on the declaration for" <+> quotes (ppr n)
+pprUserTypeCtxt (TyFamResKindCtxt n) = text "the result kind for" <+> quotes (ppr n)
+
+isSigMaybe :: UserTypeCtxt -> Maybe Name
+isSigMaybe (FunSigCtxt n _) = Just n
+isSigMaybe (ConArgCtxt n) = Just n
+isSigMaybe (ForSigCtxt n) = Just n
+isSigMaybe (PatSynCtxt n) = Just n
+isSigMaybe _ = Nothing
+
+
+{- *********************************************************************
+* *
+ ErrCtxt
+* *
+********************************************************************* -}
--------------------------------------------------------------------------------
-- type ErrCtxtMsgM = TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
@@ -113,7 +268,7 @@ data ErrCtxtMsg
-- | In the instance type signature of a class method.
| MethSigCtxt !Name !TcType !TcType
-- | In a pattern type signature.
- | PatSigErrCtxt !TcType !TcType
+ | PatSigErrCtxt !TcType !ExpType
-- | In a pattern.
| PatCtxt !(Pat GhcRn)
-- | In a pattern synonym declaration.
=====================================
compiler/GHC/Tc/Types/Origin.hs
=====================================
@@ -3,11 +3,6 @@
-- | Describes the provenance of types as they flow through the type-checker.
-- The datatypes here are mainly used for error message generation.
module GHC.Tc.Types.Origin (
- -- * UserTypeCtxt
- UserTypeCtxt(..), pprUserTypeCtxt, isSigMaybe,
- ReportRedundantConstraints(..), reportRedundantConstraints,
- redundantConstraintsSpan,
-
-- * SkolemInfo, SkolemInfoAnon
SkolemInfo(..), SkolemInfoAnon(..), mkSkolemInfo, getSkolemInfo, pprSigSkolInfo, pprSkolInfo,
unkSkol, unkSkolAnon, isStaticSkolInfo,
@@ -83,150 +78,6 @@ import qualified Data.Kind as Hs
import Data.List.NonEmpty (NonEmpty (..))
import Data.Maybe (isNothing)
-{- *********************************************************************
-* *
- UserTypeCtxt
-* *
-********************************************************************* -}
-
--------------------------------------
--- | UserTypeCtxt describes the origin of the polymorphic type
--- in the places where we need an expression to have that type
-data UserTypeCtxt
- = FunSigCtxt -- Function type signature, when checking the type
- -- Also used for types in SPECIALISE pragmas
- Name -- Name of the function
- ReportRedundantConstraints
- -- See Note [Tracking needed EvIds] in GHC.Tc.Solver
- -- This field is usually 'WantRCC', but 'NoRCC' for
- -- * Record selectors (not important here)
- -- * Class and instance methods. Here the code may legitimately
- -- be more polymorphic than the signature generated from the
- -- class declaration
- -- * Functions whose type signature has hidden the constraints
- -- behind a type synonym. E.g.
- -- type Foo = forall a. Eq a => a -> a
- -- id :: Foo
- -- id x = x
- -- Here we can't give a good location for the redundant constraints
- -- (see lhsSigWcTypeContextSpan), so we don't report redundant
- -- constraints at all. It's not clear that this a good choice;
- -- perhaps we should report, just with a less informative SrcSpan.
- -- c.f. #16154
-
- | InfSigCtxt Name -- Inferred type for function
- | ExprSigCtxt -- Expression type signature
- ReportRedundantConstraints
- | KindSigCtxt -- Kind signature
- | StandaloneKindSigCtxt -- Standalone kind signature
- Name -- Name of the type/class
- | TypeAppCtxt -- Visible type application
- | ConArgCtxt Name -- Data constructor argument
- | TySynCtxt Name -- RHS of a type synonym decl
- | PatSynCtxt Name -- Type sig for a pattern synonym
- | PatSigCtxt -- Type sig in pattern
- -- eg f (x::t) = ...
- -- or (x::t, y) = e
- | ForSigCtxt Name -- Foreign import or export signature
- | DefaultDeclCtxt -- Class or types in a default declaration
- | InstDeclCtxt Bool -- An instance declaration
- -- True: stand-alone deriving
- -- False: vanilla instance declaration
- | SpecInstCtxt -- SPECIALISE instance pragma
- | GenSigCtxt -- Higher-rank or impredicative situations
- -- e.g. (f e) where f has a higher-rank type
- -- We might want to elaborate this
- | GhciCtxt Bool -- GHCi command :kind <type>
- -- The Bool indicates if we are checking the outermost
- -- type application.
- -- See Note [Unsaturated type synonyms in GHCi] in
- -- GHC.Tc.Validity.
-
- | ClassSCCtxt Name -- Superclasses of a class
- | SigmaCtxt -- Theta part of a normal for-all type
- -- f :: <S> => a -> a
- | DataTyCtxt Name -- The "stupid theta" part of a data decl
- -- data <S> => T a = MkT a
- | DerivClauseCtxt -- A 'deriving' clause
- | TyVarBndrKindCtxt Name -- The kind of a type variable being bound
- | RuleBndrTypeCtxt Name -- The type of a term variable being bound in a RULE
- -- or SPECIALISE pragma
- -- RULE "foo" forall (x :: a -> a). f (Just x) = ...
- | DataKindCtxt Name -- The kind of a data/newtype (instance)
- | TySynKindCtxt Name -- The kind of the RHS of a type synonym
- | TyFamResKindCtxt Name -- The result kind of a type family
- deriving( Eq ) -- Just for checkSkolInfoAnon
-
--- | Report Redundant Constraints.
-data ReportRedundantConstraints
- = NoRRC -- ^ Don't report redundant constraints
-
- | WantRRC SrcSpan -- ^ Report redundant constraints
- -- The SrcSpan is for the constraints
- -- E.g. f :: (Eq a, Ord b) => blah
- -- The span is for the (Eq a, Ord b)
- -- We need to record the span here because we have
- -- long since discarded the HsType in favour of a Type
-
- deriving( Eq ) -- Just for checkSkolInfoAnon
-
-reportRedundantConstraints :: ReportRedundantConstraints -> Bool
-reportRedundantConstraints NoRRC = False
-reportRedundantConstraints (WantRRC {}) = True
-
-redundantConstraintsSpan :: UserTypeCtxt -> SrcSpan
-redundantConstraintsSpan (FunSigCtxt _ (WantRRC span)) = span
-redundantConstraintsSpan (ExprSigCtxt (WantRRC span)) = span
-redundantConstraintsSpan _ = noSrcSpan
-
-{-
--- Notes re TySynCtxt
--- We allow type synonyms that aren't types; e.g. type List = []
---
--- If the RHS mentions tyvars that aren't in scope, we'll
--- quantify over them:
--- e.g. type T = a->a
--- will become type T = forall a. a->a
---
--- With gla-exts that's right, but for H98 we should complain.
--}
-
-
-pprUserTypeCtxt :: UserTypeCtxt -> SDoc
-pprUserTypeCtxt (FunSigCtxt n _) = text "the type signature for" <+> quotes (ppr n)
-pprUserTypeCtxt (InfSigCtxt n) = text "the inferred type for" <+> quotes (ppr n)
-pprUserTypeCtxt (ExprSigCtxt _) = text "an expression type signature"
-pprUserTypeCtxt KindSigCtxt = text "a kind signature"
-pprUserTypeCtxt (StandaloneKindSigCtxt n) = text "a standalone kind signature for" <+> quotes (ppr n)
-pprUserTypeCtxt TypeAppCtxt = text "a type argument"
-pprUserTypeCtxt (ConArgCtxt c) = text "the type of the constructor" <+> quotes (ppr c)
-pprUserTypeCtxt (TySynCtxt c) = text "the RHS of the type synonym" <+> quotes (ppr c)
-pprUserTypeCtxt PatSigCtxt = text "a pattern type signature"
-pprUserTypeCtxt (ForSigCtxt n) = text "the foreign declaration for" <+> quotes (ppr n)
-pprUserTypeCtxt DefaultDeclCtxt = text "a `default' declaration"
-pprUserTypeCtxt (InstDeclCtxt False) = text "an instance declaration"
-pprUserTypeCtxt (InstDeclCtxt True) = text "a stand-alone deriving instance declaration"
-pprUserTypeCtxt SpecInstCtxt = text "a SPECIALISE instance pragma"
-pprUserTypeCtxt GenSigCtxt = text "a type expected by the context"
-pprUserTypeCtxt (GhciCtxt {}) = text "a type in a GHCi command"
-pprUserTypeCtxt (ClassSCCtxt c) = text "the super-classes of class" <+> quotes (ppr c)
-pprUserTypeCtxt SigmaCtxt = text "the context of a polymorphic type"
-pprUserTypeCtxt (DataTyCtxt tc) = text "the context of the data type declaration for" <+> quotes (ppr tc)
-pprUserTypeCtxt (PatSynCtxt n) = text "the signature for pattern synonym" <+> quotes (ppr n)
-pprUserTypeCtxt (DerivClauseCtxt) = text "a `deriving' clause"
-pprUserTypeCtxt (TyVarBndrKindCtxt n) = text "the kind annotation on the type variable" <+> quotes (ppr n)
-pprUserTypeCtxt (RuleBndrTypeCtxt n) = text "the type signature for" <+> quotes (ppr n)
-pprUserTypeCtxt (DataKindCtxt n) = text "the kind annotation on the declaration for" <+> quotes (ppr n)
-pprUserTypeCtxt (TySynKindCtxt n) = text "the kind annotation on the declaration for" <+> quotes (ppr n)
-pprUserTypeCtxt (TyFamResKindCtxt n) = text "the result kind for" <+> quotes (ppr n)
-
-isSigMaybe :: UserTypeCtxt -> Maybe Name
-isSigMaybe (FunSigCtxt n _) = Just n
-isSigMaybe (ConArgCtxt n) = Just n
-isSigMaybe (ForSigCtxt n) = Just n
-isSigMaybe (PatSynCtxt n) = Just n
-isSigMaybe _ = Nothing
-
{-
************************************************************************
* *
=====================================
compiler/GHC/Tc/Types/Origin.hs-boot
=====================================
@@ -5,7 +5,6 @@ import GHC.Utils.Misc ( HasDebugCallStack )
import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Type )
data CtOrigin
-data UserTypeCtxt
data SkolemInfoAnon
data SkolemInfo
data FixedRuntimeRepContext
=====================================
compiler/GHC/Tc/Utils/Unify.hs
=====================================
@@ -76,6 +76,8 @@ import GHC.Tc.Types.CtLoc
, tyConAppRoleExplanation, appTyRoleExplanation
)
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt( UserTypeCtxt(..), ReportRedundantConstraints(..)
+ , pprUserTypeCtxt )
import GHC.Tc.Zonk.TcType
import GHC.Tc.Utils.TcMType qualified as TcM
=====================================
compiler/GHC/Tc/Validity.hs
=====================================
@@ -26,6 +26,7 @@ import GHC.Tc.Instance.Class ( matchGlobalInst, ClsInstResult(..), AssocInstInfo
import GHC.Tc.Instance.FunDeps
import GHC.Tc.Instance.Family
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt
import GHC.Tc.Types.Rank
import GHC.Tc.Errors.Types
import GHC.Tc.Types.Constraint ( userTypeError_maybe )
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cca9b8d98d6842b8a7c963499c175f…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cca9b8d98d6842b8a7c963499c175f…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/ani/kill-SrcCodeOrigin] 6 commits: ghc-internal: avoid depending on GHC.Internal.Control.Monad.Fix
by Apoorv Ingle (@ani) 26 Feb '26
by Apoorv Ingle (@ani) 26 Feb '26
26 Feb '26
Apoorv Ingle pushed to branch wip/ani/kill-SrcCodeOrigin at Glasgow Haskell Compiler / GHC
Commits:
17839248 by Teo Camarasu at 2026-02-24T08:36:03-05:00
ghc-internal: avoid depending on GHC.Internal.Control.Monad.Fix
This module contains the definition of MonadFix, since we want an
instance for IO, that instance requires a lot of machinery and we want
to avoid an orphan instance, this will naturally be quite high up in the
dependency graph.
So we want to avoid other modules depending on it as far as possible.
On Windows, the IO manager depends on the RTSFlags type, which
transtively depends on MonadFix. We refactor things to avoid this
dependency, which would have caused a regression.
Resolves #26875
Metric Decrease:
T12227
- - - - -
fa88d09a by Wolfgang Jeltsch at 2026-02-24T08:36:47-05:00
Refine the imports of `System.IO.OS`
Commit 68bd08055594b8cbf6148a72d108786deb6c12a1 replaced the
`GHC.Internal.Data.Bool` import by a `GHC.Internal.Base` import.
However, while the `GHC.Internal.Data.Bool` import was conditional and
partial, the `GHC.Internal.Base` import is unconditional and total. As a
result, the import list is not tuned to import only the necessary bits
anymore, and furthermore GHC emits a lot of warnings about redundant
imports.
This commit makes the `GHC.Internal.Base` import conditional and partial
in the same way that the `GHC.Internal.Data.Bool` import was.
- - - - -
c951fef1 by Cheng Shao at 2026-02-25T20:58:28+00:00
wasm: add /assets endpoint to serve user-specified assets
This patch adds an `/assets` endpoint to the wasm dyld http server, so
that users can also fetch assets from the same host with sensible
default MIME types, without needing a separate http server for assets
that also introduces CORS headaches:
- A `-fghci-browser-assets-dir` driver flag is added to specify the
assets root directory (defaults to `$PWD`)
- The dyld http server fetches `mime-db` on demand and uses it as
source of truth for mime types.
Closes #26951.
- - - - -
dde22f97 by Sylvain Henry at 2026-02-26T13:14:03-05:00
Fix -fcheck-prim-bounds for non constant args (#26958)
Previously we were only checking bounds for constant (literal)
arguments!
I've refactored the code to simplify the generation of out-of-line Cmm
code for the primop composed of some inline code + some call to an
external Cmm function.
- - - - -
970c225a by Apoorv Ingle at 2026-02-26T16:35:29-06:00
Work for #25001
Notes added [Error Context Stack] [Typechecking by expansion: overview]
Notes updated Note [Expanding HsDo with XXExprGhcRn]
-------------------------
Metric Decrease:
T9020
-------------------------
* Streamlines implementations of `tcExpr` and `tcXExpr` to work on `XExpr`
* Kills `VACtxt` (and its associated `VAExpansion` and `VACall`) datatype, it is subsumed by simply a `SrcSpan`.
* Kills the function `addHeadCtxt` as it is now mearly setting a location
* The function `tcValArgs` does its own argument number management
* Makes `splitHsApps` not look through `XExpr`
* `tcExprSigma` is called if the head of the expression after calling `splitHsApps` turns out to be an `XExpr`
* Removes location information from `OrigPat` payload
* Removes special case of tcBody from `tcLambdaMatches`
* Removes special case of `dsExpr` for `ExpandedThingTc`
* Rename `HsThingRn` to `SrcCodeCtxt`
* Kills `tcl_in_gen_code` and `tcl_err_ctxt`. It is subsumed by `ErrCtxtStack`
* Kills `ExpectedFunTyOrig`. It is subsumed by `CtOrigin`
* Fixes `CtOrigin` for `HsProjection` case in `exprCtOrigin`. It was previously assigned to be `SectionOrigin`. It is now just the expression
* Adds a new `CtOrigin.ExpansionOrigin` for storing the original syntax
* Adds a new `CtOrigin.ExpectedTySyntax` as a replacement for `ExpectedTySyntaxOp`. Cannot kill the former yet because of `ApplicativeDo`
* Renames `tcMonoExpr` -> `tcMonoLExpr`, `tcMonoExprNC` -> `tcMonoLExpr`
* Renames `EValArg`, `EValArgQL` fields: `ea_ctxt` -> `ea_loc_span` and `eaql_ctx` -> `eaql_loc_span`
* kill `PopErrCtxt` from `XXExprGhcRn`
* simplify `addArgCtxt` and push `setSrcSpan` inside `addLExprCtxt`. Make sure addExprCtxt is not called by itself
* fun_orig in tcApp depends on the SrcSpan of the head of the application chain (similar to addArgCtxt)
* rename fun_ctxt to fun_lspan, fun_orig passed in tcInstFun to default to app chain head if its user located, fall back to srcCodeOrigin if it's a generated location
* fix quickLookArg function to blame the correct application chain head. The arguments application chain head should be blamed, not the original head when we quick look arg
* Make sure only expression wrapped around generated src span are ignored while adding them to the error context stack
* `getDeepSubsumptionFlag_DataConHead` performs a non-trivial traversal if the expression passed to it is complex.
This traversal is necessary if the head of the function is an `XExpr` and `splitHsApps` does not look through them
- The deepsubsumption flag is stored in EVAlArgQL to reduce the need to call `getDeepSubsumptionFlag_DataConHead`
- `getDeepSubsumptionFlag_DataConHead` is called in `tcExprSigma` and `tcInferAppHead` to reduce AST traversals
* Make a new variant `GeneratedSrcSpan` in `SrcSpan` for HIEAst Nodes
* wrap `fromListN` with a generated src span with GeneratedSrcSpanDetails field to store the original srcspan
* remove `UnhelpfulGenerated` from `UnhelpfulSpanReason` and into new datatype `GeneratedSrcSpanDetails`
- - - - -
331aac39 by Apoorv Ingle at 2026-02-26T16:36:45-06:00
trying to remove SrcCodeOrigin
- - - - -
123 changed files:
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Driver/Config/Interpreter.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/DocString.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Expr.hs-boot
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Debugger/Breakpoints.hs
- compiler/GHC/Runtime/Interpreter/Init.hs
- compiler/GHC/Runtime/Interpreter/Types.hs
- compiler/GHC/Runtime/Interpreter/Wasm.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs
- + compiler/GHC/Tc/Gen/App.hs-boot
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Expr.hs-boot
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/Origin.hs-boot
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcType.hs-boot
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Types/Error.hs
- + compiler/GHC/Types/Error.hs-boot
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/SrcLoc.hs
- + compiler/GHC/Unit/State.hs-boot
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Logger.hs
- docs/users_guide/wasm.rst
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Info.hs
- libraries/base/src/Control/Arrow.hs
- libraries/base/src/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Arrow.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Monad/Fix.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Monad/ST/Lazy/Imp.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Functor/Identity.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Windows/ManagedThreadPool.hs
- libraries/ghc-internal/src/GHC/Internal/RTS/Flags/Test.hsc
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/System/IO/OS.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs
- + testsuite/tests/codeGen/should_fail/T26958.hs
- testsuite/tests/codeGen/should_fail/all.T
- testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout
- testsuite/tests/ghci/scripts/T10963.stderr
- testsuite/tests/ghci/scripts/T4175.stdout
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- testsuite/tests/mdo/should_fail/mdofail006.stderr
- testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/rebindable/rebindable6.stderr
- testsuite/tests/rep-poly/RepPolyDoBind.stderr
- testsuite/tests/rep-poly/RepPolyDoBody1.stderr
- testsuite/tests/rep-poly/RepPolyDoBody2.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- + testsuite/tests/typecheck/should_compile/ExpansionQLIm.hs
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T3323.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/tcfail102.stderr
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail140.stderr
- testsuite/tests/typecheck/should_fail/tcfail181.stderr
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Parsers.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d15033a07de586c45d1a38dd2eb6ff…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d15033a07de586c45d1a38dd2eb6ff…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] 5 commits: ghc-internal: avoid depending on GHC.Internal.Control.Monad.Fix
by Apoorv Ingle (@ani) 26 Feb '26
by Apoorv Ingle (@ani) 26 Feb '26
26 Feb '26
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
17839248 by Teo Camarasu at 2026-02-24T08:36:03-05:00
ghc-internal: avoid depending on GHC.Internal.Control.Monad.Fix
This module contains the definition of MonadFix, since we want an
instance for IO, that instance requires a lot of machinery and we want
to avoid an orphan instance, this will naturally be quite high up in the
dependency graph.
So we want to avoid other modules depending on it as far as possible.
On Windows, the IO manager depends on the RTSFlags type, which
transtively depends on MonadFix. We refactor things to avoid this
dependency, which would have caused a regression.
Resolves #26875
Metric Decrease:
T12227
- - - - -
fa88d09a by Wolfgang Jeltsch at 2026-02-24T08:36:47-05:00
Refine the imports of `System.IO.OS`
Commit 68bd08055594b8cbf6148a72d108786deb6c12a1 replaced the
`GHC.Internal.Data.Bool` import by a `GHC.Internal.Base` import.
However, while the `GHC.Internal.Data.Bool` import was conditional and
partial, the `GHC.Internal.Base` import is unconditional and total. As a
result, the import list is not tuned to import only the necessary bits
anymore, and furthermore GHC emits a lot of warnings about redundant
imports.
This commit makes the `GHC.Internal.Base` import conditional and partial
in the same way that the `GHC.Internal.Data.Bool` import was.
- - - - -
c951fef1 by Cheng Shao at 2026-02-25T20:58:28+00:00
wasm: add /assets endpoint to serve user-specified assets
This patch adds an `/assets` endpoint to the wasm dyld http server, so
that users can also fetch assets from the same host with sensible
default MIME types, without needing a separate http server for assets
that also introduces CORS headaches:
- A `-fghci-browser-assets-dir` driver flag is added to specify the
assets root directory (defaults to `$PWD`)
- The dyld http server fetches `mime-db` on demand and uses it as
source of truth for mime types.
Closes #26951.
- - - - -
dde22f97 by Sylvain Henry at 2026-02-26T13:14:03-05:00
Fix -fcheck-prim-bounds for non constant args (#26958)
Previously we were only checking bounds for constant (literal)
arguments!
I've refactored the code to simplify the generation of out-of-line Cmm
code for the primop composed of some inline code + some call to an
external Cmm function.
- - - - -
970c225a by Apoorv Ingle at 2026-02-26T16:35:29-06:00
Work for #25001
Notes added [Error Context Stack] [Typechecking by expansion: overview]
Notes updated Note [Expanding HsDo with XXExprGhcRn]
-------------------------
Metric Decrease:
T9020
-------------------------
* Streamlines implementations of `tcExpr` and `tcXExpr` to work on `XExpr`
* Kills `VACtxt` (and its associated `VAExpansion` and `VACall`) datatype, it is subsumed by simply a `SrcSpan`.
* Kills the function `addHeadCtxt` as it is now mearly setting a location
* The function `tcValArgs` does its own argument number management
* Makes `splitHsApps` not look through `XExpr`
* `tcExprSigma` is called if the head of the expression after calling `splitHsApps` turns out to be an `XExpr`
* Removes location information from `OrigPat` payload
* Removes special case of tcBody from `tcLambdaMatches`
* Removes special case of `dsExpr` for `ExpandedThingTc`
* Rename `HsThingRn` to `SrcCodeCtxt`
* Kills `tcl_in_gen_code` and `tcl_err_ctxt`. It is subsumed by `ErrCtxtStack`
* Kills `ExpectedFunTyOrig`. It is subsumed by `CtOrigin`
* Fixes `CtOrigin` for `HsProjection` case in `exprCtOrigin`. It was previously assigned to be `SectionOrigin`. It is now just the expression
* Adds a new `CtOrigin.ExpansionOrigin` for storing the original syntax
* Adds a new `CtOrigin.ExpectedTySyntax` as a replacement for `ExpectedTySyntaxOp`. Cannot kill the former yet because of `ApplicativeDo`
* Renames `tcMonoExpr` -> `tcMonoLExpr`, `tcMonoExprNC` -> `tcMonoLExpr`
* Renames `EValArg`, `EValArgQL` fields: `ea_ctxt` -> `ea_loc_span` and `eaql_ctx` -> `eaql_loc_span`
* kill `PopErrCtxt` from `XXExprGhcRn`
* simplify `addArgCtxt` and push `setSrcSpan` inside `addLExprCtxt`. Make sure addExprCtxt is not called by itself
* fun_orig in tcApp depends on the SrcSpan of the head of the application chain (similar to addArgCtxt)
* rename fun_ctxt to fun_lspan, fun_orig passed in tcInstFun to default to app chain head if its user located, fall back to srcCodeOrigin if it's a generated location
* fix quickLookArg function to blame the correct application chain head. The arguments application chain head should be blamed, not the original head when we quick look arg
* Make sure only expression wrapped around generated src span are ignored while adding them to the error context stack
* `getDeepSubsumptionFlag_DataConHead` performs a non-trivial traversal if the expression passed to it is complex.
This traversal is necessary if the head of the function is an `XExpr` and `splitHsApps` does not look through them
- The deepsubsumption flag is stored in EVAlArgQL to reduce the need to call `getDeepSubsumptionFlag_DataConHead`
- `getDeepSubsumptionFlag_DataConHead` is called in `tcExprSigma` and `tcInferAppHead` to reduce AST traversals
* Make a new variant `GeneratedSrcSpan` in `SrcSpan` for HIEAst Nodes
* wrap `fromListN` with a generated src span with GeneratedSrcSpanDetails field to store the original srcspan
* remove `UnhelpfulGenerated` from `UnhelpfulSpanReason` and into new datatype `GeneratedSrcSpanDetails`
- - - - -
113 changed files:
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Driver/Config/Interpreter.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/DocString.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Runtime/Debugger/Breakpoints.hs
- compiler/GHC/Runtime/Interpreter/Init.hs
- compiler/GHC/Runtime/Interpreter/Types.hs
- compiler/GHC/Runtime/Interpreter/Wasm.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs
- + compiler/GHC/Tc/Gen/App.hs-boot
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Expr.hs-boot
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Types/Error.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/SrcLoc.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Logger.hs
- docs/users_guide/wasm.rst
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Info.hs
- libraries/base/src/Control/Arrow.hs
- libraries/base/src/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Arrow.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Monad/Fix.hs
- libraries/ghc-internal/src/GHC/Internal/Control/Monad/ST/Lazy/Imp.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Functor/Identity.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Windows/ManagedThreadPool.hs
- libraries/ghc-internal/src/GHC/Internal/RTS/Flags/Test.hsc
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/System/IO/OS.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs
- + testsuite/tests/codeGen/should_fail/T26958.hs
- testsuite/tests/codeGen/should_fail/all.T
- testsuite/tests/ghci/scripts/ListTuplePunsPpr.stdout
- testsuite/tests/ghci/scripts/T10963.stderr
- testsuite/tests/ghci/scripts/T4175.stdout
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- testsuite/tests/mdo/should_fail/mdofail006.stderr
- testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/rebindable/rebindable6.stderr
- testsuite/tests/rep-poly/RepPolyDoBind.stderr
- testsuite/tests/rep-poly/RepPolyDoBody1.stderr
- testsuite/tests/rep-poly/RepPolyDoBody2.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- + testsuite/tests/typecheck/should_compile/ExpansionQLIm.hs
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T3323.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/tcfail102.stderr
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail140.stderr
- testsuite/tests/typecheck/should_fail/tcfail181.stderr
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Parsers.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d3e36b867ebdbcae291f0ddd5eb54…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d3e36b867ebdbcae291f0ddd5eb54…
You're receiving this email because of your account on gitlab.haskell.org.
1
0