[Git][ghc/ghc][master] docs: fix StandaloneKindSignatures in DataKinds docs
by Marge Bot (@marge-bot) 02 Dec '25
by Marge Bot (@marge-bot) 02 Dec '25
02 Dec '25
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
fc1d7f79 by Jade Lovelace at 2025-12-02T11:04:09-05:00
docs: fix StandaloneKindSignatures in DataKinds docs
These should be `type` as otherwise GHC reports a duplicate definition
error.
- - - - -
1 changed file:
- docs/users_guide/exts/data_kinds.rst
Changes:
=====================================
docs/users_guide/exts/data_kinds.rst
=====================================
@@ -283,17 +283,17 @@ following ways:
-- REJECTED: The kind mentions Symbol, which requires DataKinds to use in
-- a kind position
- data D2 :: Symbol -> Type
+ type D2 :: Symbol -> Type
data D2 a
-- ACCEPTED: The kind mentions a type synonym MyType that expands to
-- Type, which doesn't require DataKinds
- data D3 :: MyType -> Type
+ type D3 :: MyType -> Type
data D3 a
-- REJECTED: The kind mentions a type synonym MySymbol that expands to
-- Symbol, which requires DataKinds to use in a kind position
- data D4 :: MySymbol -> Type
+ type D4 :: MySymbol -> Type
data D4 a
Unique syntax for type-level lists and tuples
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc1d7f7966f56bbe5efaf2796c430db…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc1d7f7966f56bbe5efaf2796c430db…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] Re CLC issue 292 Warn GHC.Internal.List.{init,last} are partial
by Marge Bot (@marge-bot) 02 Dec '25
by Marge Bot (@marge-bot) 02 Dec '25
02 Dec '25
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
ab20eb54 by Mike Pilgrem at 2025-12-01T22:46:55+00:00
Re CLC issue 292 Warn GHC.Internal.List.{init,last} are partial
Also corrects the warning for `tail` to refer to `Data.List.uncons` (like the existing warning for `head`).
In module `Settings.Warnings`, applies `-Wno-x-partial` to the `filepath`, and `parsec` packages (outside GHC's repository).
Also bumps submodules.
- - - - -
25 changed files:
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Driver/Session/Units.hs
- compiler/GHC/Prelude/Basic.hs
- ghc/GHCi/UI.hs
- ghc/Main.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/changelog.md
- libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
- libraries/ghc-internal/src/GHC/Internal/Float.hs
- libraries/ghc-internal/src/GHC/Internal/List.hs
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
- testsuite/tests/driver/j-space/jspace.hs
- testsuite/tests/rts/KeepCafsBase.hs
- utils/check-exact/Main.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/ghc-pkg/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
- utils/hpc
- utils/hsc2hs
Changes:
=====================================
compiler/GHC/Core/Utils.hs
=====================================
@@ -115,7 +115,6 @@ import GHC.Utils.Misc
import Data.ByteString ( ByteString )
import Data.Function ( on )
import Data.List ( sort, sortBy, partition, zipWith4, mapAccumL )
-import qualified Data.List as Partial ( init, last )
import Data.Ord ( comparing )
import Control.Monad ( guard )
import qualified Data.Set as Set
@@ -1896,10 +1895,10 @@ app_ok fun_ok primop_ok fun args
PrimOpId op _
| primOpIsDiv op
- , Lit divisor <- Partial.last args
+ , Lit divisor <- last args
-- there can be 2 args (most div primops) or 3 args
-- (WordQuotRem2Op), hence the use of last/init
- -> not (isZeroLit divisor) && all (expr_ok fun_ok primop_ok) (Partial.init args)
+ -> not (isZeroLit divisor) && all (expr_ok fun_ok primop_ok) (init args)
-- Special case for dividing operations that fail
-- In general they are NOT ok-for-speculation
-- (which primop_ok will catch), but they ARE OK
=====================================
compiler/GHC/Driver/Session/Units.hs
=====================================
@@ -39,7 +39,7 @@ import System.FilePath
import Control.Monad
import Data.List ( partition, (\\) )
import qualified Data.Set as Set
-import Prelude
+import GHC.Prelude
import GHC.ResponseFile (expandResponse)
import Data.Bifunctor
import GHC.Data.Graph.Directed
=====================================
compiler/GHC/Prelude/Basic.hs
=====================================
@@ -2,8 +2,8 @@
{-# OPTIONS_HADDOCK not-home #-}
{-# OPTIONS_GHC -O2 #-} -- See Note [-O2 Prelude]
--- See Note [Proxies for head and tail]
-{-# OPTIONS_GHC -Wno-unrecognised-warning-flags -Wno-x-partial #-}
+-- See Note [Proxies for partial list functions]
+{-# OPTIONS_GHC -Wno-x-partial #-}
-- | Custom minimal GHC "Prelude"
--
@@ -24,7 +24,7 @@ module GHC.Prelude.Basic
, bit
, shiftL, shiftR
, setBit, clearBit
- , head, tail, unzip
+ , head, tail, init, last, unzip
, strictGenericLength
) where
@@ -59,7 +59,7 @@ NoImplicitPrelude. There are two motivations for this:
-}
import qualified Prelude
-import Prelude as X hiding ((<>), Applicative(..), Foldable(..), head, tail, unzip)
+import Prelude as X hiding ((<>), Applicative(..), Foldable(..), head, tail, init, last, unzip)
import Control.Applicative (Applicative(..))
import Data.Foldable as X (Foldable (elem, foldMap, foldl, foldl', foldr, length, null, product, sum))
import Data.Foldable1 as X hiding (head, last)
@@ -118,24 +118,35 @@ setBit = \ x i -> x Bits..|. bit i
clearBit :: (Num a, Bits.Bits a) => a -> Int -> a
clearBit = \ x i -> x Bits..&. Bits.complement (bit i)
-{- Note [Proxies for head and tail]
+{- Note [Proxies for partial list functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Prelude.head and Prelude.tail have recently acquired {-# WARNING in "x-partial" #-},
+Prelude.head, Prelude.tail, Prelude.init and Prelude.last
+have recently acquired {-# WARNING in "x-partial" #-},
but the GHC codebase uses them fairly extensively and insists on building warning-free.
Thus, instead of adding {-# OPTIONS_GHC -Wno-x-partial #-} to every module which
employs them, we define warning-less proxies and export them from GHC.Prelude.
-}
--- See Note [Proxies for head and tail]
+-- See Note [Proxies for partial list functions]
head :: HasCallStack => [a] -> a
head = Prelude.head
{-# INLINE head #-}
--- See Note [Proxies for head and tail]
+-- See Note [Proxies for partial list functions]
tail :: HasCallStack => [a] -> [a]
tail = Prelude.tail
{-# INLINE tail #-}
+-- See Note [Proxies for partial list functions]
+init :: HasCallStack => [a] -> [a]
+init = Prelude.init
+{-# INLINE init #-}
+
+-- See Note [Proxies for partial list functions]
+last :: HasCallStack => [a] -> a
+last = Prelude.last
+{-# INLINE last #-}
+
{- |
The 'genericLength' function defined in base can't be specialised due to the
NOINLINE pragma.
=====================================
ghc/GHCi/UI.hs
=====================================
@@ -145,7 +145,7 @@ import Data.Time.LocalTime ( getZonedTime )
import Data.Time.Format ( formatTime, defaultTimeLocale )
import Data.Version ( showVersion )
import qualified Data.Semigroup as S
-import Prelude hiding ((<>))
+import GHC.Prelude
import GHC.Utils.Exception as Exception hiding (catch, mask, handle)
import Foreign hiding (void)
=====================================
ghc/Main.hs
=====================================
@@ -2,7 +2,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NondecreasingIndentation #-}
{-# LANGUAGE TupleSections #-}
-{-# OPTIONS -fno-warn-incomplete-patterns -optc-DNON_POSIX_SOURCE #-}
+{-# OPTIONS_GHC -Wno-x-partial -Wno-incomplete-patterns -optc-DNON_POSIX_SOURCE #-}
-----------------------------------------------------------------------------
--
=====================================
hadrian/src/Settings/Warnings.hs
=====================================
@@ -72,7 +72,11 @@ ghcWarningsArgs = do
, package terminfo ? pure [ "-Wno-unused-imports", "-Wno-deriving-typeable" ]
, package stm ? pure [ "-Wno-deriving-typeable" ]
, package osString ? pure [ "-Wno-deriving-typeable", "-Wno-unused-imports" ]
- , package parsec ? pure [ "-Wno-deriving-typeable" ]
+ , package parsec ? pure [ "-Wno-deriving-typeable"
+ , "-Wno-x-partial"
+ ]
+
+ , package filepath ? pure [ "-Wno-x-partial" ]
, package cabal ? pure [ "-Wno-deriving-typeable", "-Wno-incomplete-record-selectors" ]
-- The -Wno-incomplete-record-selectors is due to
=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,9 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
## 4.23.0.0 *TBA*
+ * Add `{-# WARNING in "x-partial" #-}` to `Data.List.{init,last}`.
+ Use `{-# OPTIONS_GHC -Wno-x-partial #-}` to disable it.
+ ([CLC proposal #87](https://github.com/haskell/core-libraries-committee/issues/292))
* Remove deprecated, unstable heap representation details from `GHC.Exts` ([CLC proposal #212](https://github.com/haskell/core-libraries-committee/issues/212))
* 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))
=====================================
libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
=====================================
@@ -1,5 +1,6 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE LambdaCase #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
-- | contains a prettyprinter for the
-- Template Haskell datatypes
=====================================
libraries/ghc-internal/src/GHC/Internal/Float.hs
=====================================
@@ -13,6 +13,9 @@
{-# OPTIONS_HADDOCK not-home #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
+-- For init in formatRealFloatAlt
+{-# OPTIONS_GHC -Wno-x-partial #-}
+
-----------------------------------------------------------------------------
-- |
-- Module : GHC.Internal.Float
=====================================
libraries/ghc-internal/src/GHC/Internal/List.hs
=====================================
@@ -190,12 +190,18 @@ tail :: HasCallStack => [a] -> [a]
tail (_:xs) = xs
tail [] = errorEmptyList "tail"
-{-# WARNING in "x-partial" tail "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use \"Data.List.NonEmpty\"." #-}
+{-# WARNING in "x-partial" tail "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'Data.List.uncons' instead. Consider refactoring to use \"Data.List.NonEmpty\"." #-}
-- | \(\mathcal{O}(n)\). Extract the last element of a list, which must be
-- finite and non-empty.
--
--- WARNING: This function is partial. Consider using 'unsnoc' instead.
+-- To disable the warning about partiality put
+-- @{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}@
+-- at the top of the file. To disable it throughout a package put the same
+-- options into @ghc-options@ section of Cabal file. To disable it in GHCi
+-- put @:set -Wno-x-partial -Wno-unrecognised-warning-flags@ into @~/.ghci@
+-- config file. See also the
+-- [migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides….
--
-- ==== __Examples__
--
@@ -218,10 +224,18 @@ last xs = foldl (\_ x -> x) lastError xs
lastError :: HasCallStack => a
lastError = errorEmptyList "last"
+{-# WARNING in "x-partial" last "This is a partial function, it throws an error on empty lists. Use 'Data.List.unsnoc' instead. Consider refactoring to use \"Data.List.NonEmpty\"." #-}
+
-- | \(\mathcal{O}(n)\). Return all the elements of a list except the last one.
-- The list must be non-empty.
--
--- WARNING: This function is partial. Consider using 'unsnoc' instead.
+-- To disable the warning about partiality put
+-- @{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}@
+-- at the top of the file. To disable it throughout a package put the same
+-- options into @ghc-options@ section of Cabal file. To disable it in GHCi
+-- put @:set -Wno-x-partial -Wno-unrecognised-warning-flags@ into @~/.ghci@
+-- config file. See also the
+-- [migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides….
--
-- ==== __Examples__
--
@@ -240,6 +254,8 @@ init (x:xs) = init' x xs
where init' _ [] = []
init' y (z:zs) = y : init' z zs
+{-# WARNING in "x-partial" init "This is a partial function, it throws an error on empty lists. Use 'Data.List.unsnoc' instead. Consider refactoring to use \"Data.List.NonEmpty\"." #-}
+
-- | \(\mathcal{O}(1)\). Test whether a list is empty.
--
-- >>> null []
=====================================
libraries/ghc-internal/src/GHC/Internal/System/IO.hs
=====================================
@@ -1,5 +1,6 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, NoImplicitPrelude, CApiFFI #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
-----------------------------------------------------------------------------
-- |
=====================================
libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
=====================================
@@ -1,4 +1,5 @@
{-# OPTIONS_HADDOCK not-home #-} -- we want users to import Language.Haskell.TH.Syntax instead
+{-# OPTIONS_GHC -Wno-x-partial #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
=====================================
libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
=====================================
@@ -1,6 +1,7 @@
-- Vendored from filepath v1.4.2.2
{-# LANGUAGE PatternGuards #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
-- This template expects CPP definitions for:
-- MODULE_NAME = Posix | Windows
=====================================
libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
=====================================
@@ -1,6 +1,7 @@
-- Vendored from filepath v1.4.2.2
{-# LANGUAGE PatternGuards #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
-- This template expects CPP definitions for:
-- MODULE_NAME = Posix | Windows
=====================================
testsuite/tests/driver/j-space/jspace.hs
=====================================
@@ -7,7 +7,7 @@ import System.Environment
import GHC.Driver.Env.Types
import GHC.Profiling
import System.Mem
-import Data.List (isPrefixOf)
+import Data.List (isPrefixOf, unsnoc)
import Control.Monad
import System.Exit
import GHC.Platform
@@ -41,7 +41,9 @@ initGhcM xs = do
requestHeapCensus
performGC
[ys] <- filter (isPrefixOf (ghcUnitId <> ":GHC.Unit.Module.ModDetails.ModDetails")) . lines <$> readFile "jspace.hp"
- let (n :: Int) = read (last (words ys))
+ let (n :: Int) = case unsnoc (words ys) of
+ Nothing -> error "input is unexpectedly empty"
+ Just (_, lst) -> read lst
-- The output should be 50 * 8 * word_size (i.e. 3600, or 1600 on 32-bit architectures):
-- the test contains DEPTH + WIDTH + 2 = 50 modules J, H_0, .., H_DEPTH, W_1, .., W_WIDTH,
-- and each ModDetails contains 1 (info table) + 8 word-sized fields.
=====================================
testsuite/tests/rts/KeepCafsBase.hs
=====================================
@@ -1,3 +1,5 @@
+{-# OPTIONS_GHC -Wno-x-partial #-}
+
module KeepCafsBase (x) where
x :: Int
=====================================
utils/check-exact/Main.hs
=====================================
@@ -6,6 +6,7 @@
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
import Data.Data
import Data.List (intercalate)
=====================================
utils/check-exact/Transform.hs
=====================================
@@ -96,6 +96,7 @@ import GHC.Data.FastString
import GHC.Types.SrcLoc
import Data.Data
+import Data.List (unsnoc)
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NE
import Data.Maybe
@@ -212,8 +213,9 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (AnnSig (EpUniTok dca u) mp md) ns (
where
-- we want DPs for the distance from the end of the ns to the
-- AnnDColon, and to the start of the ty
- rd = case last ns of
- L (EpAnn anc' _ _) _ -> epaLocationRealSrcSpan anc'
+ rd = case unsnoc ns of
+ Nothing -> error "unexpected empty list in 'ns' variable"
+ Just (_, L (EpAnn anc' _ _) _) -> epaLocationRealSrcSpan anc'
dca' = case dca of
EpaSpan ss@(RealSrcSpan r _) -> (EpaDelta ss (ss2delta (ss2posEnd rd) r) [])
_ -> dca
@@ -294,7 +296,7 @@ setEntryDP (L (EpAnn (EpaSpan ss@(RealSrcSpan r _)) an cs) a) dp
where
cs'' = setPriorComments cs []
csd = L (EpaDelta ss dp NoComments) c:commentOrigDeltas cs'
- lc = last $ (L ca c:cs')
+ lc = NE.last (L ca c :| cs')
delta = case getLoc lc of
EpaSpan (RealSrcSpan rr _) -> ss2delta (ss2pos rr) r
EpaSpan _ -> (SameLine 0)
=====================================
utils/check-exact/Utils.hs
=====================================
@@ -37,7 +37,7 @@ import GHC.Base (NonEmpty(..))
import GHC.Parser.Lexer (allocateComments)
import Data.Data hiding ( Fixity )
-import Data.List (sortBy, partition)
+import Data.List (sortBy, partition, unsnoc)
import qualified Data.Map.Strict as Map
import Debug.Trace
@@ -734,8 +734,9 @@ ghead info [] = error $ "ghead "++info++" []"
ghead _info (h:_) = h
glast :: String -> [a] -> a
-glast info [] = error $ "glast " ++ info ++ " []"
-glast _info h = last h
+glast info xs = case unsnoc xs of
+ Nothing -> error $ "glast " ++ info ++ " []"
+ Just (_, lst) -> lst
gtail :: String -> [a] -> [a]
gtail info [] = error $ "gtail " ++ info ++ " []"
=====================================
utils/ghc-pkg/Main.hs
=====================================
@@ -8,7 +8,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ScopedTypeVariables #-}
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -Wno-orphans -Wno-x-partial #-}
-- Fine if this comes from make/Hadrian or the pre-built base.
#include <ghcplatform.h>
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
=====================================
@@ -14,6 +14,7 @@ module GHC.Toolchain.Utils
import Control.Exception
import Control.Monad
import Control.Monad.IO.Class
+import Data.List (unsnoc)
import System.Directory
import System.FilePath
import System.IO.Error
@@ -67,5 +68,4 @@ isSuccess = \case
ExitFailure _ -> False
lastLine :: String -> String
-lastLine "" = ""
-lastLine s = last $ lines s
+lastLine = maybe "" snd . unsnoc . lines
=====================================
utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
=====================================
@@ -755,11 +755,15 @@ ppHtmlIndex
divAlphabet
<< unordList
( map (\str -> anchor ! [href (subIndexHtmlFile str)] << str) $
- [ [c] | c <- initialChars, any ((== c) . toUpper . head . fst) index
+ [ [c] | c <- initialChars, any (indexStartsWith c) index
]
++ [merged_name]
)
+ indexStartsWith :: Char -> (String, t) -> Bool
+ indexStartsWith c (indexChar1 : _, _) = toUpper indexChar1 == c
+ indexStartsWith _ _ = False
+
-- todo: what about names/operators that start with Unicode
-- characters?
-- Exports beginning with '_' can be listed near the end,
@@ -772,7 +776,7 @@ ppHtmlIndex
writeUtf8File (joinPath [odir, subIndexHtmlFile [c]]) (renderToString debug html)
where
html = indexPage True (Just c) index_part
- index_part = [(n, stuff) | (n, stuff) <- this_ix, toUpper (head n) == c]
+ index_part = [(n, stuff) | (n@(headN : _), stuff) <- this_ix, toUpper headN == c]
index :: [(String, Map GHC.Name [(Module, Bool)])]
index = sortBy cmp (Map.toAscList full_index)
=====================================
utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
=====================================
@@ -30,7 +30,7 @@ import Control.Arrow (first)
import Control.Monad
import Data.Char (chr, isAlpha, isSpace, isUpper)
import Data.Functor (($>))
-import Data.List (elemIndex, intercalate, intersperse, unfoldr)
+import Data.List (elemIndex, intercalate, intersperse, unfoldr, unsnoc)
import Data.Maybe (fromMaybe, mapMaybe)
import Data.Monoid
import qualified Data.Set as Set
@@ -870,10 +870,10 @@ codeblock =
DocCodeBlock . parseParagraph . dropSpaces
<$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
where
- dropSpaces xs =
- case splitByNl xs of
- [] -> xs
- ys -> case T.uncons (last ys) of
+ dropSpaces xs = let ys = splitByNl xs in
+ case unsnoc ys of
+ Nothing -> xs
+ Just (_, lastYs) -> case T.uncons lastYs of
Just (' ', _) -> case mapM dropSpace ys of
Nothing -> xs
Just zs -> T.intercalate "\n" zs
=====================================
utils/hpc
=====================================
@@ -1 +1 @@
-Subproject commit 5923da3fe77993b7afc15b5163cffcaa7da6ecf5
+Subproject commit dd43f7e139d7a4f4908d1e8af35a75939f763ef1
=====================================
utils/hsc2hs
=====================================
@@ -1 +1 @@
-Subproject commit fe3990b9f35000427b016a79330d9f195587cad8
+Subproject commit 2059c961fc28bbfd0cafdbef96d5d21f1d911b53
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab20eb5474df69dd56352a4b3e3bdaa…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab20eb5474df69dd56352a4b3e3bdaa…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
02 Dec '25
Simon Peyton Jones pushed to branch wip/T23162-part2 at Glasgow Haskell Compiler / GHC
Commits:
b261357e by Simon Peyton Jones at 2025-12-02T15:46:07+00:00
Wibbles to depth bound
- - - - -
6 changed files:
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/FunDeps.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Rewrite.hs
- compiler/GHC/Tc/Types/CtLoc.hs
Changes:
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -167,9 +167,11 @@ instance Diagnostic TcRnMessage where
-> mkSimpleDecorated $ pprSolverReportWithCtxt msg
TcRnSolverDepthError ty depth -> mkSimpleDecorated msg
where
+ pp_type_or_constraint | isConstraintLikeKind (typeKind ty) = text "constraint"
+ | otherwise = text "type"
msg =
vcat [ text "Reduction stack overflow; size =" <+> ppr depth
- , hang (text "When simplifying the following type:")
+ , hang (text "When simplifying the following" <+> pp_type_or_constraint <> colon)
2 (ppr ty) ]
TcRnRedundantConstraints redundants (info, show_info)
-> mkSimpleDecorated $
=====================================
compiler/GHC/Tc/Solver/Equality.hs
=====================================
@@ -349,11 +349,11 @@ can_eq_nc True _rdr_env _envs ev ReprEq ty1 _ ty2 _
can_eq_nc _rewritten rdr_env envs ev eq_rel ty1 ps_ty1 ty2 ps_ty2
| ReprEq <- eq_rel
, Just stuff1 <- tcTopNormaliseNewTypeTF_maybe envs rdr_env ty1
- = can_eq_newtype_nc rdr_env envs ev NotSwapped ty1 stuff1 ty2 ps_ty2
+ = can_eq_newtype_nc rdr_env envs ev NotSwapped stuff1 ty2 ps_ty2
| ReprEq <- eq_rel
, Just stuff2 <- tcTopNormaliseNewTypeTF_maybe envs rdr_env ty2
- = can_eq_newtype_nc rdr_env envs ev IsSwapped ty2 stuff2 ty1 ps_ty1
+ = can_eq_newtype_nc rdr_env envs ev IsSwapped stuff2 ty1 ps_ty1
-- Then, get rid of casts
can_eq_nc rewritten rdr_env envs ev eq_rel (CastTy ty1 co1) _ ty2 ps_ty2
@@ -777,18 +777,17 @@ though, because we check our depth in `can_eq_newtype_nc`.
can_eq_newtype_nc :: GlobalRdrEnv -> FamInstEnvs
-> CtEvidence -- ^ :: ty1 ~ ty2
-> SwapFlag
- -> TcType -- ^ ty1
-> ((Bag GlobalRdrElt, TcCoercion), TcType) -- ^ :: ty1 ~ ty1'
-> TcType -- ^ ty2
-> TcType -- ^ ty2, with type synonyms
-> TcS (StopOrContinue (Either IrredCt EqCt))
-can_eq_newtype_nc rdr_env envs ev swapped ty1 ((gres, co1), ty1') ty2 ps_ty2
+can_eq_newtype_nc rdr_env envs ev swapped ((gres, co1), ty1') ty2 ps_ty2
= do { traceTcS "can_eq_newtype_nc" $
vcat [ ppr ev, ppr swapped, ppr co1, ppr gres, ppr ty1', ppr ty2 ]
-- Check for blowing our stack, and increase the depth
-- See Note [Newtypes can blow the stack]
- ; loc' <- bumpReductionDepth (ctEvLoc ev) ty1
+ ; loc' <- bumpReductionDepth (ctEvLoc ev) (ctEvPred ev)
; let ev' = ev `setCtEvLoc` loc'
-- Next, we record uses of newtype constructors, since coercing
=====================================
compiler/GHC/Tc/Solver/FunDeps.hs
=====================================
@@ -38,6 +38,7 @@ import GHC.Utils.Panic
import GHC.Data.Pair
import Data.Maybe( isNothing, isJust, mapMaybe )
+import Control.Monad( void )
{- Note [Overview of functional dependencies in type inference]
@@ -303,17 +304,20 @@ tryDictFunDeps :: DictCt -> SolverStage ()
tryDictFunDeps dict_ct
= do { -- Note [Do local fundeps before top-level instances]
- tryDictFunDepsLocal dict_ct
- ; tryDictFunDepsTop dict_ct }
+ insoluble <- tryDictFunDepsLocal dict_ct
+ ; if insoluble
+ then nopStage ()
+ else tryDictFunDepsTop dict_ct }
-tryDictFunDepsLocal :: DictCt -> SolverStage ()
+tryDictFunDepsLocal :: DictCt -> SolverStage Bool
-- Using functional dependencies, interact the DictCt with the
-- inert Givens and Wanteds, to produce new equalities
+-- Returns True if the fundeps are insoluble
tryDictFunDepsLocal dict_ct@(DictCt { di_cls = cls, di_ev = work_ev })
| isGiven work_ev
= -- If work_ev is Given, there could in principle be some inert Wanteds
-- but in practice there never are because we solve Givens first
- nopStage ()
+ nopStage False
| otherwise
= Stage $
@@ -324,14 +328,15 @@ tryDictFunDepsLocal dict_ct@(DictCt { di_cls = cls, di_ev = work_ev })
; let eqns :: [FunDepEqns]
eqns = foldr ((++) . do_interaction) [] $
findDictsByClass (inert_dicts inerts) cls
- ; imp <- solveFunDeps work_ev eqns
+ ; (insoluble, unif_happened) <- solveFunDeps work_ev eqns
; traceTcS "tryDictFunDepsLocal }" $
- text "imp =" <+> ppr imp $$ text "eqns = " <+> ppr eqns
+ text "unif =" <+> ppr unif_happened $$ text "eqns = " <+> ppr eqns
- ; if imp then startAgainWith (CDictCan dict_ct)
- -- See (DFL1) of Note [Do fundeps last]
- else continueWith () }
+ -- See (DFL1) of Note [Do fundeps last]
+ ; if insoluble then continueWith True
+ else if unif_happened then startAgainWith (CDictCan dict_ct)
+ else continueWith False }
where
work_pred = ctEvPred work_ev
work_is_given = isGiven work_ev
@@ -356,11 +361,12 @@ tryDictFunDepsTop dict_ct@(DictCt { di_ev = ev, di_cls = cls, di_tys = xis })
; traceTcS "tryDictFunDepsTop {" (ppr dict_ct)
; let eqns :: [FunDepEqns]
eqns = improveFromInstEnv inst_envs cls xis
- ; imp <- solveFunDeps ev eqns
- ; traceTcS "tryDictFunDepsTop }" (text "imp =" <+> ppr imp)
+ ; (insoluble, unif_happened) <- solveFunDeps ev eqns
+ ; traceTcS "tryDictFunDepsTop }" (text "unif =" <+> ppr unif_happened)
- ; if imp then startAgainWith (CDictCan dict_ct)
- else continueWith () }
+ ; if not insoluble && unif_happened
+ then startAgainWith (CDictCan dict_ct)
+ else continueWith () }
{- Note [No Given/Given fundeps]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -481,12 +487,12 @@ tryFamEqFunDeps eqs_for_me fam_tc work_args
= if isGiven ev
then tryGivenBuiltinFamEqFDs eqs_for_me fam_tc ops work_args work_item
else do { -- Note [Do local fundeps before top-level instances]
- tryFDEqns fam_tc work_args work_item $
- mkLocalBuiltinFamEqFDs eqs_for_me fam_tc ops work_args work_rhs
+ insoluble <- tryFDEqns fam_tc work_args work_item $
+ mkLocalBuiltinFamEqFDs eqs_for_me fam_tc ops work_args work_rhs
- ; if hasRelevantGiven eqs_for_me work_args work_item
+ ; if insoluble || hasRelevantGiven eqs_for_me work_args work_item
; then nopStage ()
- else tryFDEqns fam_tc work_args work_item $
+ else void $ tryFDEqns fam_tc work_args work_item $
mkTopBuiltinFamEqFDs fam_tc ops work_args work_rhs }
| isGiven ev -- See (INJFAM:Given)
@@ -496,15 +502,16 @@ tryFamEqFunDeps eqs_for_me fam_tc work_args
| otherwise -- Wanted, user-defined type families
= do { -- Note [Do local fundeps before top-level instances]
- case tyConInjectivityInfo fam_tc of
- NotInjective -> nopStage()
+ insoluble <- case tyConInjectivityInfo fam_tc of
+ NotInjective -> nopStage False
Injective inj -> tryFDEqns fam_tc work_args work_item $
mkLocalFamEqFDs eqs_for_me fam_tc inj work_args work_rhs
- ; if hasRelevantGiven eqs_for_me work_args work_item
+ ; if insoluble || hasRelevantGiven eqs_for_me work_args work_item
then nopStage ()
- else tryFDEqns fam_tc work_args work_item $
- mkTopFamEqFDs fam_tc work_args work_rhs }
+ else void $ tryFDEqns fam_tc work_args work_item $
+ mkTopFamEqFDs fam_tc work_args work_rhs
+ ; nopStage () }
mkTopFamEqFDs :: TyCon -> [TcType] -> Xi -> TcS [FunDepEqns]
mkTopFamEqFDs fam_tc work_args work_rhs
@@ -526,17 +533,19 @@ mkTopFamEqFDs fam_tc work_args work_rhs
-- closed type families with no equations (isClosedFamilyTyCon_maybe returns Nothing)
return []
-tryFDEqns :: TyCon -> [TcType] -> EqCt -> TcS [FunDepEqns] -> SolverStage ()
+tryFDEqns :: TyCon -> [TcType] -> EqCt -> TcS [FunDepEqns] -> SolverStage Bool
+-- Returns True <=> some of the fundep eqns were insoluble
tryFDEqns fam_tc work_args work_item@(EqCt { eq_ev = ev, eq_rhs= rhs }) mk_fd_eqns
= Stage $
do { fd_eqns <- mk_fd_eqns
; traceTcS "tryFDEqns" (vcat [ text "lhs:" <+> ppr fam_tc <+> ppr work_args
, text "rhs:" <+> ppr rhs
, text "eqns:" <+> ppr fd_eqns ])
- ; imp <- solveFunDeps ev fd_eqns
+ ; (insoluble, unif_happened) <- solveFunDeps ev fd_eqns
- ; if imp then startAgainWith (CEqCan work_item)
- else continueWith () }
+ ; if insoluble then continueWith True
+ else if unif_happened then startAgainWith (CEqCan work_item)
+ else continueWith False }
-----------------------------------------
-- User-defined type families
@@ -878,7 +887,8 @@ solving.
solveFunDeps :: CtEvidence -- The work item
-> [FunDepEqns]
- -> TcS Bool
+ -> TcS ( Bool -- True <=> some insoluble fundeps
+ , Bool ) -- True <=> unifications happened
-- Solve a bunch of type-equality equations, generated by functional dependencies
-- By "solve" we mean: (only) do unifications. We do not generate evidence, and
-- other than unifications there should be no effects whatsoever
@@ -888,12 +898,13 @@ solveFunDeps :: CtEvidence -- The work item
-- See (SOLVE-FD) in Note [Overview of functional dependencies in type inference]
solveFunDeps work_ev fd_eqns
| null fd_eqns
- = return False -- Common case no-op
+ = return (False, False) -- Common case no-op
| otherwise
- = do { loc' <- bumpReductionDepth (ctEvLoc work_ev) (ctEvPred work_ev)
+ = do { traceTcS "bumping" (ppr work_ev)
+ ; loc' <- bumpReductionDepth (ctEvLoc work_ev) (ctEvPred work_ev)
- ; (unifs, _res)
+ ; (unifs, residual)
<- reportFineGrainUnifications $
nestFunDepsTcS $
TcS.pushTcLevelM_ $
@@ -911,7 +922,7 @@ solveFunDeps work_ev fd_eqns
-- that were unified by the fundep
; kickOutAfterUnification unifs
- ; return (not (isEmptyVarSet unifs)) }
+ ; return (insolubleWC residual, not (isEmptyVarSet unifs)) }
where
do_fundeps :: UnifyEnv -> TcM ()
do_fundeps env = mapM_ (do_one env) fd_eqns
=====================================
compiler/GHC/Tc/Solver/Monad.hs
=====================================
@@ -2182,7 +2182,8 @@ newWantedNC loc rewriters pty
-- | Checks if the depth of the given location is too much. Fails if
-- it's too big, with an appropriate error message.
-bumpReductionDepth :: CtLoc -> TcType -- ^ type being reduced
+bumpReductionDepth :: CtLoc
+ -> TcType -- ^ type or constraint being reduced
-> TcS CtLoc
bumpReductionDepth loc ty
= do { dflags <- getDynFlags
=====================================
compiler/GHC/Tc/Solver/Rewrite.hs
=====================================
@@ -11,7 +11,7 @@ import GHC.Tc.Types ( TcGblEnv(tcg_tc_plugin_rewriters),
RewriteEnv(..),
runTcPluginM )
import GHC.Tc.Types.Constraint
-import GHC.Tc.Types.CtLoc( CtLoc )
+import GHC.Tc.Types.CtLoc( CtLoc, resetCtLocDepth )
import GHC.Core.Predicate
import GHC.Tc.Utils.TcType
import GHC.Core.Type
@@ -90,7 +90,8 @@ runRewriteCtEv ev
runRewrite :: CtLoc -> CtFlavour -> EqRel -> RewriteM a -> TcS (a, CoHoleSet)
runRewrite loc flav eq_rel thing_inside
= do { rewriters_ref <- newTcRef emptyCoHoleSet
- ; let fmode = RE { re_loc = loc
+ ; let fmode = RE { re_loc = resetCtLocDepth loc
+ -- Start reducing from zero
, re_flavour = flav
, re_eq_rel = eq_rel
, re_rewriters = rewriters_ref }
@@ -792,8 +793,7 @@ rewrite_fam_app tc tys -- Can be over-saturated
-- See Note [How to normalise a family application]
rewrite_exact_fam_app :: TyCon -> [TcType] -> RewriteM Reduction
rewrite_exact_fam_app tc tys
- = bumpReductionDepthRM (mkTyConApp tc tys) $
- do { -- Query the typechecking plugins for all their rewriting functions
+ = do { -- Query the typechecking plugins for all their rewriting functions
-- which apply to a type family application headed by the TyCon 'tc'.
; tc_rewriters <- getTcPluginRewritersForTyCon tc
@@ -876,7 +876,8 @@ rewrite_exact_fam_app tc tys
-> Reduction -> RewriteM Reduction
finish use_cache redn
= do { -- rewrite the result: FINISH 1
- final_redn <- rewrite_reduction redn
+ final_redn <- bumpReductionDepthRM (mkTyConApp tc tys) $
+ rewrite_reduction redn
; eq_rel <- getEqRel
-- extend the cache: FINISH 2
=====================================
compiler/GHC/Tc/Types/CtLoc.hs
=====================================
@@ -3,7 +3,8 @@ module GHC.Tc.Types.CtLoc (
-- * CtLoc
CtLoc(..), ctLocSpan, ctLocEnv, ctLocLevel, ctLocOrigin,
ctLocTypeOrKind_maybe, toInvisibleLoc,
- ctLocDepth, bumpCtLocDepth, isGivenLoc, mkGivenLoc, mkKindEqLoc,
+ ctLocDepth, bumpCtLocDepth, resetCtLocDepth,
+ isGivenLoc, mkGivenLoc, mkKindEqLoc,
setCtLocOrigin, updateCtLocOrigin, setCtLocEnv, setCtLocSpan,
pprCtLoc, adjustCtLoc, adjustCtLocTyConBinder,
@@ -196,6 +197,9 @@ setCtLocSpan ctl@(CtLoc { ctl_env = lcl }) loc = setCtLocEnv ctl (setCtLocRealLo
bumpCtLocDepth :: CtLoc -> CtLoc
bumpCtLocDepth loc@(CtLoc { ctl_depth = d }) = loc { ctl_depth = bumpSubGoalDepth d }
+resetCtLocDepth :: CtLoc -> CtLoc
+resetCtLocDepth loc = loc { ctl_depth = initialSubGoalDepth }
+
setCtLocOrigin :: CtLoc -> CtOrigin -> CtLoc
setCtLocOrigin ctl orig = ctl { ctl_origin = orig }
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b261357e6067ca0717371d8ebdeeb30…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b261357e6067ca0717371d8ebdeeb30…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Zubin pushed new tag ghc-9.14.1-rc3 at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.14.1-rc3
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][ghc-9.14] 2 commits: rts: fix eager black holes: record mutated closure and fix assertion
by Zubin (@wz1000) 02 Dec '25
by Zubin (@wz1000) 02 Dec '25
02 Dec '25
Zubin pushed to branch ghc-9.14 at Glasgow Haskell Compiler / GHC
Commits:
bcc68c56 by Luite Stegeman at 2025-11-25T18:23:46+05:30
rts: fix eager black holes: record mutated closure and fix assertion
This fixes two problems with handling eager black holes, introduced
by a1de535f762bc23d4cf23a5b1853591dda12cdc9.
- the closure mutation must be recorded even for eager black holes,
since the mutator has mutated it before calling threadPaused
- The assertion that an unmarked eager black hole must be owned by
the TSO calling threadPaused is incorrect, since multiple threads
can race to claim the black hole.
fixes #26495
(cherry picked from commit 3ba3d9f9db784c903ebe8fd617447ce62d30b7d3)
- - - - -
85e8147d by Zubin Duggal at 2025-11-28T14:00:24+05:30
rts/linker/PEi386: Copy strings before they are inserted into LoadedDllCache. The original strings are temporary and might be freed at an arbitrary point.
Fixes #26613
(cherry picked from commit 5072da477b8ec883aea4b9ea27763fcc1971af1a)
- - - - -
2 changed files:
- rts/ThreadPaused.c
- rts/linker/PEi386.c
Changes:
=====================================
rts/ThreadPaused.c
=====================================
@@ -321,11 +321,12 @@ threadPaused(Capability *cap, StgTSO *tso)
if(frame_info == &stg_bh_upd_frame_info) {
// eager black hole: we do nothing
- // it should be a black hole that we own
+ // it should be a black hole (but we may not own it, as another
+ // thread could have raced us to claim it)
ASSERT(bh_info == &stg_BLACKHOLE_info ||
bh_info == &__stg_EAGER_BLACKHOLE_info ||
bh_info == &stg_CAF_BLACKHOLE_info);
- ASSERT(blackHoleOwner(bh) == tso || blackHoleOwner(bh) == NULL);
+
} else {
// lazy black hole
@@ -368,13 +369,15 @@ threadPaused(Capability *cap, StgTSO *tso)
// The payload of the BLACKHOLE points to the TSO
RELEASE_STORE(&((StgInd *)bh)->indirectee, (StgClosure *)tso);
SET_INFO_RELEASE(bh,&stg_BLACKHOLE_info);
+ }
- // .. and we need a write barrier, since we just mutated the closure:
- recordClosureMutated(cap,bh);
+ // We need a write barrier, since the closure was mutated (by
+ // threadPaused for lazy black holes, or the mutator for eager
+ // black holes).
+ recordClosureMutated(cap,bh);
- // We pretend that bh has just been created.
- LDV_RECORD_CREATE(bh);
- }
+ // We pretend that bh has just been created.
+ LDV_RECORD_CREATE(bh);
frame = (StgClosure *) ((StgUpdateFrame *)frame + 1);
if (prev_was_update_frame) {
=====================================
rts/linker/PEi386.c
=====================================
@@ -552,7 +552,12 @@ static int compare_path(StgWord key1, StgWord key2)
static void addLoadedDll(LoadedDllCache *cache, const pathchar *dll_name, HINSTANCE instance)
{
- insertHashTable_(cache->hash, (StgWord) dll_name, instance, hash_path);
+ // dll_name might be deallocated, we need to copy it to have a stable reference to the contents
+ // See #26613
+ size_t size = wcslen(dll_name) + 1;
+ pathchar* dll_name_copy = stgMallocBytes(size * sizeof(pathchar), "addLoadedDll");
+ wcsncpy(dll_name_copy, dll_name, size);
+ insertHashTable_(cache->hash, (StgWord) dll_name_copy, instance, hash_path);
}
static HINSTANCE isDllLoaded(const LoadedDllCache *cache, const pathchar *dll_name)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0e08b9aee6ce58fe7099f14ac1d7de…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0e08b9aee6ce58fe7099f14ac1d7de…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: hadrian: Place user options after package arguments
by Marge Bot (@marge-bot) 02 Dec '25
by Marge Bot (@marge-bot) 02 Dec '25
02 Dec '25
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
0d7c05ec by Ben Gamari at 2025-12-01T03:13:46-05:00
hadrian: Place user options after package arguments
This makes it easier for the user to override the default package
arguments with `UserSettings.hs`.
Fixes #25821.
-------------------------
Metric Decrease:
T14697
-------------------------
- - - - -
3b2c4598 by Vladislav Zavialov at 2025-12-01T03:14:29-05:00
Namespace-specified wildcards in import/export lists (#25901)
This change adds support for top-level namespace-specified wildcards
`type ..` and `data ..` to import and export lists.
Examples:
import M (type ..) -- imports all type and class constructors from M
import M (data ..) -- imports all data constructors and terms from M
module M (type .., f) where
-- exports all type and class constructors defined in M,
-- plus the function 'f'
The primary intended usage of this feature is in combination with module
aliases, allowing namespace disambiguation:
import Data.Proxy as T (type ..) -- T.Proxy is unambiguously the type constructor
import Data.Proxy as D (data ..) -- D.Proxy is unambiguously the data constructor
The patch accounts for the interactions of wildcards with:
* Imports with `hiding` clauses
* Import warnings -Wunused-imports, -Wdodgy-imports
* Export warnings -Wduplicate-exports, -Wdodgy-exports
Summary of the changes:
1. Move the NamespaceSpecifier type from GHC.Hs.Binds to GHC.Hs.Basic,
making it possible to use it in more places in the AST.
2. Extend the AST (type: IE) with a representation of `..`, `type ..`,
and `data ..` (constructor: IEWholeNamespace). Per the proposal, the
plain `..` is always rejected with a dedicated error message.
3. Extend the grammar in Parser.y with productions for `..`, `type ..`,
and `data ..` in both import and export lists.
4. Implement wildcard imports by updating the `filterImports` function
in GHC.Rename.Names; the logic for IEWholeNamespace is roughly
modeled after the Nothing (no explicit import list) case.
5. Implement wildcard exports by updating the `exports_from_avail`
function in GHC.Tc.Gen.Export; the logic for IEWholeNamespace is
closely modeled after the IEModuleContents case.
6. Refactor and extend diagnostics to report the new warnings and
errors. See PsErrPlainWildcardImport, DodgyImportsWildcard,
PsErrPlainWildcardExport, DodgyExportsWildcard,
TcRnDupeWildcardExport.
Note that this patch is specifically about top-level import/export
items. Subordinate import/export items are left unchanged.
- - - - -
c71faa76 by Luite Stegeman at 2025-12-01T03:16:05-05:00
rts: Handle overflow of ELF section header string table
If the section header string table is stored in a section greater
than or equal to SHN_LORESERVE (0xff00), the 16-bit field e_shstrndx
in the ELF header does not contain the section number, but rather
an overflow value SHN_XINDEX (0xffff) indicating that we need to look
elsewhere.
This fixes the linker by not using e_shstrndx directly but calling
elf_shstrndx, which correctly handles the SHN_XINDEX value.
Fixes #26603
- - - - -
ab20eb54 by Mike Pilgrem at 2025-12-01T22:46:55+00:00
Re CLC issue 292 Warn GHC.Internal.List.{init,last} are partial
Also corrects the warning for `tail` to refer to `Data.List.uncons` (like the existing warning for `head`).
In module `Settings.Warnings`, applies `-Wno-x-partial` to the `filepath`, and `parsec` packages (outside GHC's repository).
Also bumps submodules.
- - - - -
3b8b4331 by Jade Lovelace at 2025-12-02T04:22:55-05:00
docs: fix StandaloneKindSignatures in DataKinds docs
These should be `type` as otherwise GHC reports a duplicate definition
error.
- - - - -
109 changed files:
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Driver/Session/Units.hs
- compiler/GHC/Hs/Basic.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Prelude/Basic.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/ImpExp.hs
- docs/users_guide/9.16.1-notes.rst
- docs/users_guide/exts/data_kinds.rst
- docs/users_guide/exts/explicit_namespaces.rst
- ghc/GHCi/UI.hs
- ghc/Main.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/changelog.md
- libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
- libraries/ghc-internal/src/GHC/Internal/Float.hs
- libraries/ghc-internal/src/GHC/Internal/List.hs
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
- rts/linker/Elf.c
- testsuite/tests/driver/j-space/jspace.hs
- + testsuite/tests/module/T25901_exp_plain_wc.hs
- + testsuite/tests/module/T25901_exp_plain_wc.stderr
- + testsuite/tests/module/T25901_imp_plain_wc.hs
- + testsuite/tests/module/T25901_imp_plain_wc.stderr
- testsuite/tests/module/all.T
- + testsuite/tests/rename/should_compile/T25901_exp_1.hs
- + testsuite/tests/rename/should_compile/T25901_exp_1_helper.hs
- + testsuite/tests/rename/should_compile/T25901_exp_2.hs
- + testsuite/tests/rename/should_compile/T25901_exp_2_helper.hs
- + testsuite/tests/rename/should_compile/T25901_imp_hq.hs
- + testsuite/tests/rename/should_compile/T25901_imp_hu.hs
- + testsuite/tests/rename/should_compile/T25901_imp_sq.hs
- + testsuite/tests/rename/should_compile/T25901_imp_su.hs
- testsuite/tests/rename/should_compile/all.T
- + testsuite/tests/rename/should_fail/T25901_exp_fail_1.hs
- + testsuite/tests/rename/should_fail/T25901_exp_fail_1.stderr
- + testsuite/tests/rename/should_fail/T25901_exp_fail_1_helper.hs
- + testsuite/tests/rename/should_fail/T25901_exp_fail_2.hs
- + testsuite/tests/rename/should_fail/T25901_exp_fail_2.stderr
- + testsuite/tests/rename/should_fail/T25901_exp_fail_2_helper.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_5.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_5.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_6.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_6.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_hu_fail_4.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hu_fail_4.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_2.hs
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_2.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_3.hs
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_3.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_su_fail_1.hs
- + testsuite/tests/rename/should_fail/T25901_imp_su_fail_1.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rts/KeepCafsBase.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dodgy.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dodgy.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_1.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_1.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_2.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_2.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_3.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_3.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_4.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_4.stderr
- + testsuite/tests/warnings/should_compile/T25901_helper_1.hs
- + testsuite/tests/warnings/should_compile/T25901_helper_2.hs
- + testsuite/tests/warnings/should_compile/T25901_helper_3.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_1.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_1.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_2.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_2.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_1.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_1.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_2.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_2.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_3.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_3.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_4.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_4.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Main.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/ghc-pkg/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
- utils/hpc
- utils/hsc2hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc6b1e980030bdc3a32996cd1bd7fc…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc6b1e980030bdc3a32996cd1bd7fc…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T23162-part2] 2 commits: Use a depth limit in fundeps
by Simon Peyton Jones (@simonpj) 02 Dec '25
by Simon Peyton Jones (@simonpj) 02 Dec '25
02 Dec '25
Simon Peyton Jones pushed to branch wip/T23162-part2 at Glasgow Haskell Compiler / GHC
Commits:
6db30500 by Simon Peyton Jones at 2025-12-02T00:11:51+00:00
Use a depth limit in fundeps
- - - - -
bab28604 by Simon Peyton Jones at 2025-12-02T00:37:48+00:00
wibbles
- - - - -
6 changed files:
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/FunDeps.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Rewrite.hs
Changes:
=====================================
compiler/GHC/Tc/Solver/Default.hs
=====================================
@@ -508,6 +508,10 @@ defaultEquality encl_eqs ct
= return False
where
+ ev = ctEvidence ct
+ rws = ctEvRewriters ev
+ loc = ctEvLoc ev
+
-- try_default_tv_nom: used for tv ~#N ty
try_default_tv_nom lhs_tv rhs_ty
| MetaTv { mtv_info = info } <- tcTyVarDetails lhs_tv
@@ -546,7 +550,7 @@ defaultEquality encl_eqs ct
= do { traceTcS "defaultEquality success:" (ppr rhs_ty)
; unifyTyVar lhs_tv rhs_ty -- NB: unifyTyVar adds to the
-- TcS unification counter
- ; setEqIfWanted (ctEvidence ct) (mkReflCPH NomEq rhs_ty)
+ ; setEqIfWanted ev (mkReflCPH NomEq rhs_ty)
; return True
}
@@ -561,7 +565,7 @@ defaultEquality encl_eqs ct
-- This handles cases such as @IO alpha[tau] ~R# IO Int@
-- by defaulting @alpha := Int@, which is useful in practice
-- (see Note [Defaulting representational equalities]).
- ; (co, new_eqs) <- wrapUnifier (ctEvidence ct) Nominal $ \uenv ->
+ ; (co, new_eqs) <- wrapUnifier rws loc Nominal $ \uenv ->
-- NB: nominal equality!
uType uenv z_ty1 z_ty2
@@ -571,7 +575,7 @@ defaultEquality encl_eqs ct
-- See Note [Defaulting representational equalities].
; if null new_eqs
then do { traceTcS "defaultEquality ReprEq } (yes)" empty
- ; setEqIfWanted (ctEvidence ct) $
+ ; setEqIfWanted ev $
CPH { cph_co = mkSubCo co, cph_holes = emptyCoHoleSet }
; return True }
else do { traceTcS "defaultEquality ReprEq } (no)" empty
=====================================
compiler/GHC/Tc/Solver/Dict.hs
=====================================
@@ -4,7 +4,6 @@
-- | Solving Class constraints CDictCan
module GHC.Tc.Solver.Dict (
solveDict, solveDictNC, solveCallStack,
- checkInstanceOK,
matchLocalInst, chooseInstance,
makeSuperClasses, mkStrictSuperClasses
) where
@@ -857,8 +856,22 @@ chooseInstance work_item@(WantedCt { ctev_dest = dest, ctev_rewriters = rws
, cir_mk_ev = mk_ev
, cir_canonical = canonical })
= do { traceTcS "doTopReact/found instance for" $ ppr work_item
- ; deeper_loc <- checkInstanceOK loc what pred
- ; checkReductionDepth deeper_loc pred
+
+ -- Check that the dfun is well-staged in the Template Haskell sense
+ ; checkWellLevelledDFun loc what pred
+
+ -- zapped_loc: after applying an instance we can set ScOrigin to
+ -- NotNakedSc, so that prohibitedSuperClassSolve never fires
+ -- See Note [Solving superclass constraints] in
+ -- GHC.Tc.TyCl.Instance, (sc1).
+ ; let zapped_loc | ScOrigin what _ <- ctLocOrigin loc
+ = setCtLocOrigin loc (ScOrigin what NotNakedSc)
+ | otherwise
+ = loc
+
+ -- Deeper location for new constraints
+ ; deeper_loc <- bumpReductionDepth zapped_loc pred
+
; assertPprM (getTcEvBindsVar >>= return . not . isCoEvBindsVar)
(ppr work_item)
; evc_vars <- mapM (newWanted deeper_loc rws) theta
@@ -868,27 +881,6 @@ chooseInstance work_item@(WantedCt { ctev_dest = dest, ctev_rewriters = rws
chooseInstance work_item lookup_res
= pprPanic "chooseInstance" (ppr work_item $$ ppr lookup_res)
-checkInstanceOK :: CtLoc -> InstanceWhat -> TcPredType -> TcS CtLoc
--- Check that it's OK to use this instance:
--- (a) the use is well staged in the Template Haskell sense
--- Returns the CtLoc to used for sub-goals
--- Probably also want to call checkReductionDepth
-checkInstanceOK loc what pred
- = do { checkWellLevelledDFun loc what pred
- ; return deeper_loc }
- where
- deeper_loc = zap_origin (bumpCtLocDepth loc)
- origin = ctLocOrigin loc
-
- zap_origin loc -- After applying an instance we can set ScOrigin to
- -- NotNakedSc, so that prohibitedSuperClassSolve never fires
- -- See Note [Solving superclass constraints] in
- -- GHC.Tc.TyCl.Instance, (sc1).
- | ScOrigin what _ <- origin
- = setCtLocOrigin loc (ScOrigin what NotNakedSc)
- | otherwise
- = loc
-
matchClassInst :: DynFlags -> InertSet
-> Class -> [Type]
-> CtLoc -> TcS ClsInstResult
=====================================
compiler/GHC/Tc/Solver/Equality.hs
=====================================
@@ -486,7 +486,7 @@ can_eq_nc_forall :: CtEvidence -> EqRel
-- See Note [Solving forall equalities]
can_eq_nc_forall ev eq_rel s1 s2
- | CtWanted (WantedCt { ctev_dest = orig_dest }) <- ev
+ | CtWanted (WantedCt { ctev_dest = orig_dest, ctev_rewriters = rws, ctev_loc = loc }) <- ev
= do { let (bndrs1, phi1, bndrs2, phi2) = split_foralls s1 s2
flags1 = binderFlags bndrs1
flags2 = binderFlags bndrs2
@@ -550,7 +550,7 @@ can_eq_nc_forall ev eq_rel s1 s2
do { -- Generate constraints
(tclvl, (all_co, wanteds))
<- pushLevelNoWorkList (ppr skol_info) $
- wrapUnifier ev (eqRelRole eq_rel) $ \uenv ->
+ wrapUnifier rws loc (eqRelRole eq_rel) $ \uenv ->
go uenv skol_tvs init_subst2 bndrs1 bndrs2
; traceTcS "Trying to solve the implication" (ppr s1 $$ ppr s2 $$ ppr wanteds)
@@ -788,9 +788,8 @@ can_eq_newtype_nc rdr_env envs ev swapped ty1 ((gres, co1), ty1') ty2 ps_ty2
-- Check for blowing our stack, and increase the depth
-- See Note [Newtypes can blow the stack]
- ; let loc = ctEvLoc ev
- ev' = ev `setCtEvLoc` bumpCtLocDepth loc
- ; checkReductionDepth loc ty1
+ ; loc' <- bumpReductionDepth (ctEvLoc ev) ty1
+ ; let ev' = ev `setCtEvLoc` loc'
-- Next, we record uses of newtype constructors, since coercing
-- through newtypes is tantamount to using their constructors.
@@ -1689,9 +1688,9 @@ canEqCanLHSHetero ev eq_rel swapped lhs1 ps_xi1 ki1 xi2 ps_xi2 ki2
; emitWorkNC [CtGiven kind_ev]
; finish emptyCoHoleSet (givenCtEvCoercion kind_ev) }
- CtWanted {}
+ CtWanted (WantedCt { ctev_loc = loc, ctev_rewriters = rws })
-> do { (unifs, (kind_co, eqs)) <- reportFineGrainUnifications $
- wrapUnifier ev Nominal $ \uenv ->
+ wrapUnifier rws loc Nominal $ \uenv ->
let uenv' = updUEnvLoc uenv (mkKindEqLoc xi1 xi2)
in uType uenv' ki2 ki1
-- kind_co :: ki2 ~N ki1
=====================================
compiler/GHC/Tc/Solver/FunDeps.hs
=====================================
@@ -25,7 +25,6 @@ import GHC.Core.FamInstEnv
import GHC.Core.Coercion
import GHC.Core.Predicate( EqRel(..) )
import GHC.Core.TyCon
-import GHC.Core.TyCo.Rep( Type(..) )
import GHC.Core.Unify( tcUnifyTysForInjectivity, typeListsAreApart )
import GHC.Core.Coercion.Axiom
import GHC.Core.TyCo.Subst( elemSubst )
@@ -36,7 +35,6 @@ import GHC.Types.Var.Set
import GHC.Utils.Outputable
import GHC.Utils.Panic
-import GHC.Utils.Misc( lengthExceeds )
import GHC.Data.Pair
import Data.Maybe( isNothing, isJust, mapMaybe )
@@ -545,25 +543,11 @@ tryFDEqns fam_tc work_args work_item@(EqCt { eq_ev = ev, eq_rhs= rhs }) mk_fd_eq
-----------------------------------------
mkTopClosedFamEqFDs :: CoAxiom Branched -> [TcType] -> Xi -> TcS [FunDepEqns]
mkTopClosedFamEqFDs ax work_args work_rhs
- | isInformativeType work_rhs -- Does RHS have anything useful to say?
= do { let branches = fromBranches (coAxiomBranches ax)
; traceTcS "mkTopClosed" (ppr branches $$ ppr work_args $$ ppr work_rhs)
; case getRelevantBranches ax work_args work_rhs of
[eqn] -> return [eqn] -- If there is just one relevant equation, use it
_ -> return [] }
- | otherwise
- = return []
-
-isInformativeType :: Type -> Bool
--- The type is headed by something generative, not just
--- a type variable or a type-family application
-isInformativeType ty | Just ty' <- coreView ty = isInformativeType ty'
-isInformativeType (CastTy ty _) = isInformativeType ty
-isInformativeType (TyVarTy {}) = False
-isInformativeType (CoercionTy {}) = False -- Moot
-isInformativeType (TyConApp tc tys) = isGenerativeTyCon tc Nominal ||
- tys `lengthExceeds` tyConArity tc
-isInformativeType _ = True -- AppTy, ForAllTy, FunTy, LitTy
hasRelevantGiven :: [EqCt] -> [TcType] -> EqCt -> Bool
-- A Given is relevant if it is not apart from the Wanted
@@ -907,14 +891,17 @@ solveFunDeps work_ev fd_eqns
= return False -- Common case no-op
| otherwise
- = do { (unifs, _res)
+ = do { loc' <- bumpReductionDepth (ctEvLoc work_ev) (ctEvPred work_ev)
+
+ ; (unifs, _res)
<- reportFineGrainUnifications $
nestFunDepsTcS $
TcS.pushTcLevelM_ $
-- pushTcLevelTcM: increase the level so that unification variables
-- allocated by the fundep-creation itself don't count as useful unifications
-- See Note [Deeper TcLevel for partial improvement unification variables]
- do { (_, eqs) <- wrapUnifier work_ev Nominal do_fundeps
+ do { (_, eqs) <- wrapUnifier (ctEvRewriters work_ev) loc' Nominal $
+ do_fundeps
; solveSimpleWanteds eqs }
-- Why solveSimpleWanteds? Answer
-- (a) We don't want to rely on the eager unifier being clever
@@ -938,7 +925,7 @@ instantiateFunDepEqns (FDEqns { fd_qtvs = tvs, fd_eqs = eqs })
| null tvs
= return rev_eqs
| otherwise
- = do { TcM.traceTc "emitFunDepWanteds 2" (ppr tvs $$ ppr eqs)
+ = do { TcM.traceTc "instantiateFunDepEqns" (ppr tvs $$ ppr eqs)
; (_, subst) <- instFlexiXTcM emptySubst tvs -- Takes account of kind substitution
; return (map (subst_pair subst) rev_eqs) }
where
=====================================
compiler/GHC/Tc/Solver/Monad.hs
=====================================
@@ -58,7 +58,7 @@ module GHC.Tc.Solver.Monad (
setEvBind, setWantedEq, setWantedDict, setEqIfWanted, setDictIfWanted,
fillCoercionHole,
newEvVar, newGivenEv, emitNewGivens,
- emitChildEqs, checkReductionDepth,
+ emitChildEqs, bumpReductionDepth,
getInstEnvs, getFamInstEnvs, -- Getting the environments
getTopEnv, getGblEnv, getLclEnv, setSrcSpan,
@@ -1810,8 +1810,6 @@ selectNextWorkItem
pick_me ct new_wl
= do { writeTcRef wl_var new_wl
; return (Just ct) }
- -- NB: no need for checkReductionDepth (ctLoc ct) (ctPred ct)
- -- This is done by GHC.Tc.Solver.Dict.chooseInstance
-- try_rws looks through rw_eqs to find one that has an empty
-- rewriter set, after zonking. If none such, call try_rest.
@@ -2184,12 +2182,13 @@ newWantedNC loc rewriters pty
-- | Checks if the depth of the given location is too much. Fails if
-- it's too big, with an appropriate error message.
-checkReductionDepth :: CtLoc -> TcType -- ^ type being reduced
- -> TcS ()
-checkReductionDepth loc ty
+bumpReductionDepth :: CtLoc -> TcType -- ^ type being reduced
+ -> TcS CtLoc
+bumpReductionDepth loc ty
= do { dflags <- getDynFlags
; when (subGoalDepthExceeded (reductionDepth dflags) (ctLocDepth loc)) $
- wrapErrTcS $ solverDepthError loc ty }
+ wrapErrTcS $ solverDepthError loc ty
+ ; return (bumpCtLocDepth loc) }
matchFam :: TyCon -> [Type] -> TcS (Maybe ReductionN)
matchFam tycon args = wrapTcS $ matchFamTcM tycon args
@@ -2258,7 +2257,8 @@ wrapUnifierAndEmit :: CtEvidence -> Role
-- returns a CoHoleSet describing the new unsolved goals
wrapUnifierAndEmit ev role do_unifications
= do { (unifs, (co, eqs)) <- reportFineGrainUnifications $
- wrapUnifier ev role do_unifications
+ wrapUnifier (ctEvRewriters ev) (ctEvLoc ev) role $
+ do_unifications
-- Emit the deferred constraints
; emitChildEqs ev eqs
@@ -2268,7 +2268,7 @@ wrapUnifierAndEmit ev role do_unifications
; return (CPH { cph_co = co, cph_holes = rewriterSetFromCts eqs }) }
-wrapUnifier :: CtEvidence -> Role
+wrapUnifier :: CoHoleSet -> CtLoc -> Role
-> (UnifyEnv -> TcM a) -- Some calls to uType
-> TcS (a, Bag Ct)
-- Invokes the do_unifications argument, with a suitable UnifyEnv.
@@ -2276,7 +2276,7 @@ wrapUnifier :: CtEvidence -> Role
-- See Note [wrapUnifier]
-- The (Bag Ct) are the deferred constraints; we emit them but
-- also return them
-wrapUnifier ev role do_unifications
+wrapUnifier rws loc role do_unifications
= do { given_eq_lvl <- getInnermostGivenEqLevel
; what_uni <- getWhatUnifications
@@ -2284,8 +2284,8 @@ wrapUnifier ev role do_unifications
do { defer_ref <- TcM.newTcRef emptyBag
; let env = UE { u_role = role
, u_given_eq_lvl = given_eq_lvl
- , u_rewriters = ctEvRewriters ev
- , u_loc = ctEvLoc ev
+ , u_rewriters = rws
+ , u_loc = loc
, u_defer = defer_ref
, u_what = what_uni }
-- u_rewriters: the rewriter set and location from
=====================================
compiler/GHC/Tc/Solver/Rewrite.hs
=====================================
@@ -11,7 +11,7 @@ import GHC.Tc.Types ( TcGblEnv(tcg_tc_plugin_rewriters),
RewriteEnv(..),
runTcPluginM )
import GHC.Tc.Types.Constraint
-import GHC.Tc.Types.CtLoc( CtLoc, bumpCtLocDepth )
+import GHC.Tc.Types.CtLoc( CtLoc )
import GHC.Core.Predicate
import GHC.Tc.Utils.TcType
import GHC.Core.Type
@@ -125,14 +125,6 @@ getFlavourRole
; eq_rel <- getEqRel
; return (flavour, eq_rel) }
-getLoc :: RewriteM CtLoc
-getLoc = getRewriteEnvField re_loc
-
-checkStackDepth :: Type -> RewriteM ()
-checkStackDepth ty
- = do { loc <- getLoc
- ; liftTcS $ checkReductionDepth loc ty }
-
-- | Change the 'EqRel' in a 'RewriteM'.
setEqRel :: EqRel -> RewriteM a -> RewriteM a
setEqRel new_eq_rel thing_inside
@@ -142,12 +134,13 @@ setEqRel new_eq_rel thing_inside
else runRewriteM thing_inside (env { re_eq_rel = new_eq_rel })
{-# INLINE setEqRel #-}
-bumpDepth :: RewriteM a -> RewriteM a
-bumpDepth (RewriteM thing_inside)
+bumpReductionDepthRM :: Type -> RewriteM a -> RewriteM a
+bumpReductionDepthRM ty (RewriteM thing_inside)
= mkRewriteM $ \env -> do
- -- bumpDepth can be called a lot during rewriting so we force the
- -- new env to avoid accumulating thunks.
- { let !env' = env { re_loc = bumpCtLocDepth (re_loc env) }
+ { loc' <- TcS.bumpReductionDepth (re_loc env) ty
+ ; let !env' = env { re_loc = loc' }
+ -- !env: bumpReductionDepth can be called a lot during rewriting
+ -- so we force the new env to avoid accumulating thunks
; thing_inside env' }
recordRewriter :: CtEvidence -> RewriteM ()
@@ -584,7 +577,7 @@ rewrite_co co = liftTcS $ zonkCo co
-- | Rewrite a reduction, composing the resulting coercions.
rewrite_reduction :: Reduction -> RewriteM Reduction
rewrite_reduction (Reduction co xi)
- = do { redn <- bumpDepth $ rewrite_one xi
+ = do { redn <- rewrite_one xi
; return $ co `mkTransRedn` redn }
-- rewrite (nested) AppTys
@@ -799,10 +792,9 @@ rewrite_fam_app tc tys -- Can be over-saturated
-- See Note [How to normalise a family application]
rewrite_exact_fam_app :: TyCon -> [TcType] -> RewriteM Reduction
rewrite_exact_fam_app tc tys
- = do { checkStackDepth (mkTyConApp tc tys)
-
- -- Query the typechecking plugins for all their rewriting functions
- -- which apply to a type family application headed by the TyCon 'tc'.
+ = bumpReductionDepthRM (mkTyConApp tc tys) $
+ do { -- Query the typechecking plugins for all their rewriting functions
+ -- which apply to a type family application headed by the TyCon 'tc'.
; tc_rewriters <- getTcPluginRewritersForTyCon tc
-- STEP 1. Try to reduce without reducing arguments first.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9106adf35ef38c62d2720b0ed761d3…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9106adf35ef38c62d2720b0ed761d3…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] wrap expanded records in an XExpr. Accept test cases
by Apoorv Ingle (@ani) 02 Dec '25
by Apoorv Ingle (@ani) 02 Dec '25
02 Dec '25
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
d9e481ee by Apoorv Ingle at 2025-12-01T18:25:06-06:00
wrap expanded records in an XExpr. Accept test cases
- - - - -
7 changed files:
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Expr.hs
- testsuite/tests/default/default-fail05.stderr
- testsuite/tests/indexed-types/should_fail/T1897b.stderr
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
Changes:
=====================================
compiler/GHC/Tc/Gen/App.hs
=====================================
@@ -679,10 +679,6 @@ quickLookKeys = [dollarIdKey, leftSectionKey, rightSectionKey]
* *
********************************************************************* -}
--- setQLInstLevel :: QLFlag -> TcM a -> TcM a
--- setQLInstLevel DoQL thing_inside = setTcLevel QLInstVar thing_inside
--- setQLInstLevel NoQL thing_inside = thing_inside
-
tcInstFun :: QLFlag
-> Bool -- False <=> Instantiate only /top-level, inferred/ variables;
-- so may return a sigma-type
@@ -706,9 +702,7 @@ tcInstFun do_ql inst_final ds_flag (fun_orig, rn_fun, fun_lspan) tc_fun fun_sigm
, text "args:" <+> ppr rn_args
, text "do_ql" <+> ppr do_ql
, text "ctx" <+> ppr fun_lspan])
- ; res@(_, fun_ty) <- -- setQLInstLevel do_ql $ -- See (TCAPP1) and (TCAPP2) in
- -- Note [tcApp: typechecking applications]
- go 1 [] fun_sigma rn_args
+ ; res@(_, fun_ty) <- go 1 [] fun_sigma rn_args
; traceTc "tcInstFun:ret" (ppr fun_ty)
; return res
}
=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -671,7 +671,7 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr
, recUpdFields = rbnds }
})
res_ty
- = assert (notNull rbnds) $
+ = assert (notNull rbnds) $ mkExpandedExprTc expr <$>
do { -- Expand the record update. See Note [Record Updates].
; (ds_expr, ds_res_ty, err_msg)
=====================================
testsuite/tests/default/default-fail05.stderr
=====================================
@@ -1,7 +1,7 @@
default-fail05.hs:11:10: error: [GHC-39999]
- • Ambiguous type variable ‘t0’ arising from a use of ‘toList’
- prevents the constraint ‘(Foldable t0)’ from being solved.
- Probable fix: use a type annotation to specify what ‘t0’ should be.
+ • Ambiguous type variable ‘f0’ arising from a use of ‘toList’
+ prevents the constraint ‘(Foldable f0)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘f0’ should be.
Potentially matching instances:
instance Foldable (Either a)
-- Defined in ‘GHC.Internal.Data.Foldable’
@@ -14,9 +14,9 @@ default-fail05.hs:11:10: error: [GHC-39999]
In a stmt of a 'do' block: print (toList $ pure 21)
default-fail05.hs:11:19: error: [GHC-39999]
- • Ambiguous type variable ‘t0’ arising from a use of ‘pure’
- prevents the constraint ‘(Applicative t0)’ from being solved.
- Probable fix: use a type annotation to specify what ‘t0’ should be.
+ • Ambiguous type variable ‘f0’ arising from a use of ‘pure’
+ prevents the constraint ‘(Applicative f0)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘f0’ should be.
Potentially matching instances:
instance Applicative IO -- Defined in ‘GHC.Internal.Base’
instance Applicative Maybe -- Defined in ‘GHC.Internal.Base’
@@ -28,11 +28,11 @@ default-fail05.hs:11:19: error: [GHC-39999]
In a stmt of a 'do' block: print (toList $ pure 21)
default-fail05.hs:12:3: error: [GHC-39999]
- • Ambiguous type variable ‘t1’ arising from a use of ‘traverse’
- prevents the constraint ‘(Traversable t1)’ from being solved.
+ • Ambiguous type variable ‘t0’ arising from a use of ‘traverse’
+ prevents the constraint ‘(Traversable t0)’ from being solved.
Relevant bindings include
- main :: IO (t1 ()) (bound at default-fail05.hs:10:1)
- Probable fix: use a type annotation to specify what ‘t1’ should be.
+ main :: IO (t0 ()) (bound at default-fail05.hs:10:1)
+ Probable fix: use a type annotation to specify what ‘t0’ should be.
Potentially matching instances:
instance Traversable (Either a)
-- Defined in ‘GHC.Internal.Data.Traversable’
@@ -51,11 +51,11 @@ default-fail05.hs:12:3: error: [GHC-39999]
traverse print (pure 42)
default-fail05.hs:12:19: error: [GHC-39999]
- • Ambiguous type variable ‘t1’ arising from a use of ‘pure’
- prevents the constraint ‘(Applicative t1)’ from being solved.
+ • Ambiguous type variable ‘t0’ arising from a use of ‘pure’
+ prevents the constraint ‘(Applicative t0)’ from being solved.
Relevant bindings include
- main :: IO (t1 ()) (bound at default-fail05.hs:10:1)
- Probable fix: use a type annotation to specify what ‘t1’ should be.
+ main :: IO (t0 ()) (bound at default-fail05.hs:10:1)
+ Probable fix: use a type annotation to specify what ‘t0’ should be.
Potentially matching instances:
instance Applicative IO -- Defined in ‘GHC.Internal.Base’
instance Applicative Maybe -- Defined in ‘GHC.Internal.Base’
=====================================
testsuite/tests/indexed-types/should_fail/T1897b.stderr
=====================================
@@ -1,14 +1,14 @@
T1897b.hs:16:1: error: [GHC-83865]
- • Couldn't match type: Depend a0
- with: Depend a
- Expected: t (Depend a) -> Bool
- Actual: t (Depend a0) -> Bool
+ • Couldn't match type: Depend b0
+ with: Depend b
+ Expected: t (Depend b) -> Bool
+ Actual: t (Depend b0) -> Bool
Note: ‘Depend’ is a non-injective type family.
- The type variable ‘a0’ is ambiguous
+ The type variable ‘b0’ is ambiguous
• In the ambiguity check for the inferred type for ‘isValid’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the inferred type
- isValid :: forall {t :: * -> *} {a}.
- (Foldable t, Bug a) =>
- t (Depend a) -> Bool
+ isValid :: forall {t :: * -> *} {b}.
+ (Foldable t, Bug b) =>
+ t (Depend b) -> Bool
=====================================
testsuite/tests/typecheck/should_compile/T14590.stderr
=====================================
@@ -1,7 +1,6 @@
T14590.hs:4:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int -> Int -> Int
- • In the expression: x `_`
- In the expression: (x `_`) y
+ • In the expression: (x `_`) y
In an equation for ‘f1’: f1 x y = (x `_`) y
• Relevant bindings include
y :: Int (bound at T14590.hs:4:6)
@@ -88,8 +87,7 @@ T14590.hs:4:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
T14590.hs:5:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _a :: Int -> Int -> Int
Or perhaps ‘_a’ is mis-spelled, or not in scope
- • In the expression: x `_a`
- In the expression: (x `_a`) y
+ • In the expression: (x `_a`) y
In an equation for ‘f2’: f2 x y = (x `_a`) y
• Relevant bindings include
y :: Int (bound at T14590.hs:5:6)
@@ -175,8 +173,7 @@ T14590.hs:5:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
T14590.hs:6:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int -> Int -> Int
- • In the expression: `_` x
- In the expression: (`_` x) y
+ • In the expression: (`_` x) y
In an equation for ‘f3’: f3 x y = (`_` x) y
• Relevant bindings include
y :: Int (bound at T14590.hs:6:6)
@@ -263,8 +260,7 @@ T14590.hs:6:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
T14590.hs:7:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _a :: Int -> Int -> Int
Or perhaps ‘_a’ is mis-spelled, or not in scope
- • In the expression: `_a` x
- In the expression: (`_a` x) y
+ • In the expression: (`_a` x) y
In an equation for ‘f4’: f4 x y = (`_a` x) y
• Relevant bindings include
y :: Int (bound at T14590.hs:7:6)
=====================================
testsuite/tests/typecheck/should_fail/T6069.stderr
=====================================
@@ -23,5 +23,5 @@ T6069.hs:15:16: error: [GHC-83865]
Actual: (forall s. ST s b2) -> b2
• In the second argument of ‘(.)’, namely ‘runST’
In the first argument of ‘($)’, namely ‘(print . runST)’
- In the expression: (print . runST) $
+ In the expression: ((print . runST) $) fourty_two
=====================================
testsuite/tests/typecheck/should_fail/T7857.stderr
=====================================
@@ -1,7 +1,7 @@
T7857.hs:8:11: error: [GHC-39999]
• Could not deduce ‘PrintfType a0’ arising from a use of ‘printf’
- from the context: PrintfArg q
- bound by the inferred type of g :: PrintfArg q => q -> b
+ from the context: PrintfArg t
+ bound by the inferred type of g :: PrintfArg t => t -> b
at T7857.hs:8:1-21
The type variable ‘a0’ is ambiguous
Potentially matching instances:
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9e481eef6d66164a3c597c455d88bb…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d9e481eef6d66164a3c597c455d88bb…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] wrap expanded records in an XExpr. Accept test cases
by Apoorv Ingle (@ani) 02 Dec '25
by Apoorv Ingle (@ani) 02 Dec '25
02 Dec '25
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
6f597b8f by Apoorv Ingle at 2025-12-01T18:24:08-06:00
wrap expanded records in an XExpr. Accept test cases
- - - - -
6 changed files:
- compiler/GHC/Tc/Gen/Expr.hs
- testsuite/tests/default/default-fail05.stderr
- testsuite/tests/indexed-types/should_fail/T1897b.stderr
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T7857.stderr
Changes:
=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -671,7 +671,7 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr
, recUpdFields = rbnds }
})
res_ty
- = assert (notNull rbnds) $
+ = assert (notNull rbnds) $ mkExpandedExprTc expr <$>
do { -- Expand the record update. See Note [Record Updates].
; (ds_expr, ds_res_ty, err_msg)
=====================================
testsuite/tests/default/default-fail05.stderr
=====================================
@@ -1,7 +1,7 @@
default-fail05.hs:11:10: error: [GHC-39999]
- • Ambiguous type variable ‘t0’ arising from a use of ‘toList’
- prevents the constraint ‘(Foldable t0)’ from being solved.
- Probable fix: use a type annotation to specify what ‘t0’ should be.
+ • Ambiguous type variable ‘f0’ arising from a use of ‘toList’
+ prevents the constraint ‘(Foldable f0)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘f0’ should be.
Potentially matching instances:
instance Foldable (Either a)
-- Defined in ‘GHC.Internal.Data.Foldable’
@@ -14,9 +14,9 @@ default-fail05.hs:11:10: error: [GHC-39999]
In a stmt of a 'do' block: print (toList $ pure 21)
default-fail05.hs:11:19: error: [GHC-39999]
- • Ambiguous type variable ‘t0’ arising from a use of ‘pure’
- prevents the constraint ‘(Applicative t0)’ from being solved.
- Probable fix: use a type annotation to specify what ‘t0’ should be.
+ • Ambiguous type variable ‘f0’ arising from a use of ‘pure’
+ prevents the constraint ‘(Applicative f0)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘f0’ should be.
Potentially matching instances:
instance Applicative IO -- Defined in ‘GHC.Internal.Base’
instance Applicative Maybe -- Defined in ‘GHC.Internal.Base’
@@ -28,11 +28,11 @@ default-fail05.hs:11:19: error: [GHC-39999]
In a stmt of a 'do' block: print (toList $ pure 21)
default-fail05.hs:12:3: error: [GHC-39999]
- • Ambiguous type variable ‘t1’ arising from a use of ‘traverse’
- prevents the constraint ‘(Traversable t1)’ from being solved.
+ • Ambiguous type variable ‘t0’ arising from a use of ‘traverse’
+ prevents the constraint ‘(Traversable t0)’ from being solved.
Relevant bindings include
- main :: IO (t1 ()) (bound at default-fail05.hs:10:1)
- Probable fix: use a type annotation to specify what ‘t1’ should be.
+ main :: IO (t0 ()) (bound at default-fail05.hs:10:1)
+ Probable fix: use a type annotation to specify what ‘t0’ should be.
Potentially matching instances:
instance Traversable (Either a)
-- Defined in ‘GHC.Internal.Data.Traversable’
@@ -51,11 +51,11 @@ default-fail05.hs:12:3: error: [GHC-39999]
traverse print (pure 42)
default-fail05.hs:12:19: error: [GHC-39999]
- • Ambiguous type variable ‘t1’ arising from a use of ‘pure’
- prevents the constraint ‘(Applicative t1)’ from being solved.
+ • Ambiguous type variable ‘t0’ arising from a use of ‘pure’
+ prevents the constraint ‘(Applicative t0)’ from being solved.
Relevant bindings include
- main :: IO (t1 ()) (bound at default-fail05.hs:10:1)
- Probable fix: use a type annotation to specify what ‘t1’ should be.
+ main :: IO (t0 ()) (bound at default-fail05.hs:10:1)
+ Probable fix: use a type annotation to specify what ‘t0’ should be.
Potentially matching instances:
instance Applicative IO -- Defined in ‘GHC.Internal.Base’
instance Applicative Maybe -- Defined in ‘GHC.Internal.Base’
=====================================
testsuite/tests/indexed-types/should_fail/T1897b.stderr
=====================================
@@ -1,14 +1,14 @@
T1897b.hs:16:1: error: [GHC-83865]
- • Couldn't match type: Depend a0
- with: Depend a
- Expected: t (Depend a) -> Bool
- Actual: t (Depend a0) -> Bool
+ • Couldn't match type: Depend b0
+ with: Depend b
+ Expected: t (Depend b) -> Bool
+ Actual: t (Depend b0) -> Bool
Note: ‘Depend’ is a non-injective type family.
- The type variable ‘a0’ is ambiguous
+ The type variable ‘b0’ is ambiguous
• In the ambiguity check for the inferred type for ‘isValid’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the inferred type
- isValid :: forall {t :: * -> *} {a}.
- (Foldable t, Bug a) =>
- t (Depend a) -> Bool
+ isValid :: forall {t :: * -> *} {b}.
+ (Foldable t, Bug b) =>
+ t (Depend b) -> Bool
=====================================
testsuite/tests/typecheck/should_compile/T14590.stderr
=====================================
@@ -1,7 +1,6 @@
T14590.hs:4:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int -> Int -> Int
- • In the expression: x `_`
- In the expression: (x `_`) y
+ • In the expression: (x `_`) y
In an equation for ‘f1’: f1 x y = (x `_`) y
• Relevant bindings include
y :: Int (bound at T14590.hs:4:6)
@@ -88,8 +87,7 @@ T14590.hs:4:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
T14590.hs:5:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _a :: Int -> Int -> Int
Or perhaps ‘_a’ is mis-spelled, or not in scope
- • In the expression: x `_a`
- In the expression: (x `_a`) y
+ • In the expression: (x `_a`) y
In an equation for ‘f2’: f2 x y = (x `_a`) y
• Relevant bindings include
y :: Int (bound at T14590.hs:5:6)
@@ -175,8 +173,7 @@ T14590.hs:5:13: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
T14590.hs:6:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int -> Int -> Int
- • In the expression: `_` x
- In the expression: (`_` x) y
+ • In the expression: (`_` x) y
In an equation for ‘f3’: f3 x y = (`_` x) y
• Relevant bindings include
y :: Int (bound at T14590.hs:6:6)
@@ -263,8 +260,7 @@ T14590.hs:6:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
T14590.hs:7:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _a :: Int -> Int -> Int
Or perhaps ‘_a’ is mis-spelled, or not in scope
- • In the expression: `_a` x
- In the expression: (`_a` x) y
+ • In the expression: (`_a` x) y
In an equation for ‘f4’: f4 x y = (`_a` x) y
• Relevant bindings include
y :: Int (bound at T14590.hs:7:6)
=====================================
testsuite/tests/typecheck/should_fail/T6069.stderr
=====================================
@@ -23,5 +23,5 @@ T6069.hs:15:16: error: [GHC-83865]
Actual: (forall s. ST s b2) -> b2
• In the second argument of ‘(.)’, namely ‘runST’
In the first argument of ‘($)’, namely ‘(print . runST)’
- In the expression: (print . runST) $
+ In the expression: ((print . runST) $) fourty_two
=====================================
testsuite/tests/typecheck/should_fail/T7857.stderr
=====================================
@@ -1,7 +1,7 @@
T7857.hs:8:11: error: [GHC-39999]
• Could not deduce ‘PrintfType a0’ arising from a use of ‘printf’
- from the context: PrintfArg q
- bound by the inferred type of g :: PrintfArg q => q -> b
+ from the context: PrintfArg t
+ bound by the inferred type of g :: PrintfArg t => t -> b
at T7857.hs:8:1-21
The type variable ‘a0’ is ambiguous
Potentially matching instances:
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f597b8f46463be88529d4664f42e98…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f597b8f46463be88529d4664f42e98…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/warning-for-last-and-init] 20 commits: Add nubOrd / nubOrdBy to Data.List and Data.List.NonEmpty
by Bodigrim (@Bodigrim) 01 Dec '25
by Bodigrim (@Bodigrim) 01 Dec '25
01 Dec '25
Bodigrim pushed to branch wip/warning-for-last-and-init at Glasgow Haskell Compiler / GHC
Commits:
b7b7c049 by Andrew Lelechenko at 2025-11-21T21:04:01+00:00
Add nubOrd / nubOrdBy to Data.List and Data.List.NonEmpty
As per https://github.com/haskell/core-libraries-committee/issues/336
- - - - -
352d5462 by Marc Scholten at 2025-11-22T10:33:03-05:00
Fix haddock test runner to handle UTF-8 output
xhtml 3000.4.0.0 now produces UTF-8 output instead of escaping non-ASCII characters.
When using --test-accept it previously wrote files in the wrong encoding
because they have not been decoded properly when reading the files.
- - - - -
48a3ed57 by Simon Peyton Jones at 2025-11-25T15:33:54+00:00
Add a fast-path for args=[] to occAnalApp
In the common case of having not arguments, occAnalApp
was doing redundant work.
- - - - -
951e5ed9 by Simon Peyton Jones at 2025-11-25T15:33:54+00:00
Fix a performance hole in the occurrence analyser
As #26425 showed, the clever stuff in
Note [Occurrence analysis for join points]
does a lot of duplication of usage details. This patch
improved matters with a little fancy footwork. It is
described in the new (W4) of the same Note.
Compile-time allocations go down slightly. Here are the changes
of +/- 0.5% or more:
T13253(normal) 329,369,244 326,395,544 -0.9%
T13253-spj(normal) 66,410,496 66,095,864 -0.5%
T15630(normal) 129,797,200 128,663,136 -0.9%
T15630a(normal) 129,212,408 128,027,560 -0.9%
T16577(normal) 6,756,706,896 6,723,028,512 -0.5%
T18282(normal) 128,462,070 125,808,584 -2.1% GOOD
T18698a(normal) 208,418,305 202,037,336 -3.1% GOOD
T18730(optasm) 136,981,756 136,208,136 -0.6%
T18923(normal) 58,103,088 57,745,840 -0.6%
T19695(normal) 1,386,306,272 1,365,609,416 -1.5%
T26425(normal) 3,344,402,957 2,457,811,664 -26.5% GOOD
T6048(optasm) 79,763,816 79,212,760 -0.7%
T9020(optasm) 225,278,408 223,682,440 -0.7%
T9961(normal) 303,810,717 300,729,168 -1.0% GOOD
geo. mean -0.5%
minimum -26.5%
maximum +0.4%
Metric Decrease:
T18282
T18698a
T26425
T9961
- - - - -
f1959dfc by Simon Peyton Jones at 2025-11-26T11:58:07+00:00
Remove a quadratic-cost assertion check in mkCoreApp
See the new Note [Assertion checking in mkCoreApp]
- - - - -
98fa0d36 by Simon Hengel at 2025-11-27T17:54:57-05:00
Fix typo in docs/users_guide/exts/type_families.rst
- - - - -
5b97e5ce by Simon Hengel at 2025-11-27T17:55:37-05:00
Fix broken RankNTypes example in user's guide
- - - - -
fa2aaa00 by Simon Peyton Jones at 2025-11-27T17:56:18-05:00
Switch off specialisation in ExactPrint
In !15057 (where we re-introduced -fpolymoprhic-specialisation) we found
that ExactPrint's compile time blew up by a factor of 5. It turned out
to be caused by bazillions of specialisations of `markAnnotated`.
Since ExactPrint isn't perf-critical, it does not seem worth taking
the performance hit, so this patch switches off specialisation in
this one module.
- - - - -
1fd25987 by Simon Peyton Jones at 2025-11-27T17:56:18-05:00
Switch -fpolymorphic-specialisation on by default
This patch addresses #23559.
Now that !10479 has landed and #26329 is fixed, we can switch on
polymorphic specialisation by default, addressing a bunch of other
tickets listed in #23559.
Metric changes:
* CoOpt_Singleton: +4% compiler allocations: we just get more
specialisations
* info_table_map_perf: -20% decrease in compiler allocations.
This is caused by using -fno-specialise in ExactPrint.hs
Without that change we get a 4x blow-up in compile time;
see !15058 for details
Metric Decrease:
info_table_map_perf
Metric Increase:
CoOpt_Singletons
- - - - -
b7fe7445 by Matthew Pickering at 2025-11-27T17:56:59-05:00
rts: Fix a deadlock with eventlog flush interval and RTS shutdown
The ghc_ticker thread attempts to flush at the eventlog tick interval, this requires
waiting to take all capabilities.
At the same time, the main thread is shutting down, the schedule is
stopped and then we wait for the ticker thread to finish.
Therefore we are deadlocked.
The solution is to use `newBoundTask/exitMyTask`, so that flushing can
cooperate with the scheduler shutdown.
Fixes #26573
- - - - -
1d4a1229 by sheaf at 2025-11-27T17:58:02-05:00
SimpleOpt: don't subst in pushCoercionIntoLambda
It was noticed in #26589 that the change in 15b311be was incorrect:
the simple optimiser carries two different substitution-like pieces of
information: 'soe_subst' (from InVar to OutExpr) and 'soe_inl'
(from InId to InExpr). It is thus incorrect to have 'pushCoercionIntoLambda'
apply the substitution from 'soe_subst' while discarding 'soe_inl'
entirely, which is what was done in 15b311be.
Instead, we change back pushCoercionIntoLambda to take an InScopeSet,
and optimise the lambda before calling 'pushCoercionIntoLambda' to avoid
mixing InExpr with OutExpr, or mixing two InExpr with different
environments. We can then call 'soeZapSubst' without problems.
Fixes #26588 #26589
- - - - -
84a087d5 by Sylvain Henry at 2025-11-28T17:35:28-05:00
Fix PIC jump tables on Windows (#24016)
Avoid overflows in jump tables by using a base label closer to the jump
targets. See added Note [Jump tables]
- - - - -
82db7042 by Zubin Duggal at 2025-11-28T17:36:10-05:00
rts/linker/PEi386: Copy strings before they are inserted into LoadedDllCache. The original strings are temporary and might be freed at an arbitrary point.
Fixes #26613
- - - - -
ff3f0d09 by Ben Gamari at 2025-11-29T18:34:28-05:00
gitlab-ci: Run ghcup-metadata jobs on OpenCape runners
This significantly reduces our egress traffic
and makes the jobs significantly faster.
- - - - -
ef0dc33b by Matthew Pickering at 2025-11-29T18:35:10-05:00
Use 'OsPath' in getModificationTimeIfExists
This part of the compiler is quite hot during recompilation checking in
particular since the filepaths will be translated to a string. It is
better to use the 'OsPath' native function, which turns out to be easy
to do.
- - - - -
fa3bd0a6 by Georgios Karachalias at 2025-11-29T18:36:05-05:00
Use OsPath in PkgDbRef and UnitDatabase, not FilePath
- - - - -
0d7c05ec by Ben Gamari at 2025-12-01T03:13:46-05:00
hadrian: Place user options after package arguments
This makes it easier for the user to override the default package
arguments with `UserSettings.hs`.
Fixes #25821.
-------------------------
Metric Decrease:
T14697
-------------------------
- - - - -
3b2c4598 by Vladislav Zavialov at 2025-12-01T03:14:29-05:00
Namespace-specified wildcards in import/export lists (#25901)
This change adds support for top-level namespace-specified wildcards
`type ..` and `data ..` to import and export lists.
Examples:
import M (type ..) -- imports all type and class constructors from M
import M (data ..) -- imports all data constructors and terms from M
module M (type .., f) where
-- exports all type and class constructors defined in M,
-- plus the function 'f'
The primary intended usage of this feature is in combination with module
aliases, allowing namespace disambiguation:
import Data.Proxy as T (type ..) -- T.Proxy is unambiguously the type constructor
import Data.Proxy as D (data ..) -- D.Proxy is unambiguously the data constructor
The patch accounts for the interactions of wildcards with:
* Imports with `hiding` clauses
* Import warnings -Wunused-imports, -Wdodgy-imports
* Export warnings -Wduplicate-exports, -Wdodgy-exports
Summary of the changes:
1. Move the NamespaceSpecifier type from GHC.Hs.Binds to GHC.Hs.Basic,
making it possible to use it in more places in the AST.
2. Extend the AST (type: IE) with a representation of `..`, `type ..`,
and `data ..` (constructor: IEWholeNamespace). Per the proposal, the
plain `..` is always rejected with a dedicated error message.
3. Extend the grammar in Parser.y with productions for `..`, `type ..`,
and `data ..` in both import and export lists.
4. Implement wildcard imports by updating the `filterImports` function
in GHC.Rename.Names; the logic for IEWholeNamespace is roughly
modeled after the Nothing (no explicit import list) case.
5. Implement wildcard exports by updating the `exports_from_avail`
function in GHC.Tc.Gen.Export; the logic for IEWholeNamespace is
closely modeled after the IEModuleContents case.
6. Refactor and extend diagnostics to report the new warnings and
errors. See PsErrPlainWildcardImport, DodgyImportsWildcard,
PsErrPlainWildcardExport, DodgyExportsWildcard,
TcRnDupeWildcardExport.
Note that this patch is specifically about top-level import/export
items. Subordinate import/export items are left unchanged.
- - - - -
c71faa76 by Luite Stegeman at 2025-12-01T03:16:05-05:00
rts: Handle overflow of ELF section header string table
If the section header string table is stored in a section greater
than or equal to SHN_LORESERVE (0xff00), the 16-bit field e_shstrndx
in the ELF header does not contain the section number, but rather
an overflow value SHN_XINDEX (0xffff) indicating that we need to look
elsewhere.
This fixes the linker by not using e_shstrndx directly but calling
elf_shstrndx, which correctly handles the SHN_XINDEX value.
Fixes #26603
- - - - -
ab20eb54 by Mike Pilgrem at 2025-12-01T22:46:55+00:00
Re CLC issue 292 Warn GHC.Internal.List.{init,last} are partial
Also corrects the warning for `tail` to refer to `Data.List.uncons` (like the existing warning for `head`).
In module `Settings.Warnings`, applies `-Wno-x-partial` to the `filepath`, and `parsec` packages (outside GHC's repository).
Also bumps submodules.
- - - - -
163 changed files:
- .gitlab-ci.yml
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Data/OsPath.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/CodeOutput.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Driver/Session/Units.hs
- compiler/GHC/Hs/Basic.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Prelude/Basic.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Unique/Set.hs
- compiler/GHC/Types/Var/Env.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Utils/Misc.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/ImpExp.hs
- docs/users_guide/9.16.1-notes.rst
- docs/users_guide/exts/explicit_namespaces.rst
- docs/users_guide/exts/rank_polymorphism.rst
- docs/users_guide/exts/type_families.rst
- docs/users_guide/phases.rst
- docs/users_guide/using-optimisation.rst
- ghc/GHCi/UI.hs
- ghc/Main.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- libraries/base/src/Data/List.hs
- libraries/base/src/Data/List/NonEmpty.hs
- + libraries/base/src/Data/List/NubOrdSet.hs
- libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
- libraries/ghc-internal/src/GHC/Internal/Data/OldList.hs
- libraries/ghc-internal/src/GHC/Internal/Float.hs
- libraries/ghc-internal/src/GHC/Internal/List.hs
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
- rts/eventlog/EventLog.c
- rts/linker/Elf.c
- rts/linker/PEi386.c
- + testsuite/tests/codeGen/should_run/T24016.hs
- + testsuite/tests/codeGen/should_run/T24016.stdout
- testsuite/tests/codeGen/should_run/all.T
- testsuite/tests/driver/j-space/jspace.hs
- 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/module/T25901_exp_plain_wc.hs
- + testsuite/tests/module/T25901_exp_plain_wc.stderr
- + testsuite/tests/module/T25901_imp_plain_wc.hs
- + testsuite/tests/module/T25901_imp_plain_wc.stderr
- testsuite/tests/module/all.T
- + testsuite/tests/rename/should_compile/T25901_exp_1.hs
- + testsuite/tests/rename/should_compile/T25901_exp_1_helper.hs
- + testsuite/tests/rename/should_compile/T25901_exp_2.hs
- + testsuite/tests/rename/should_compile/T25901_exp_2_helper.hs
- + testsuite/tests/rename/should_compile/T25901_imp_hq.hs
- + testsuite/tests/rename/should_compile/T25901_imp_hu.hs
- + testsuite/tests/rename/should_compile/T25901_imp_sq.hs
- + testsuite/tests/rename/should_compile/T25901_imp_su.hs
- testsuite/tests/rename/should_compile/all.T
- + testsuite/tests/rename/should_fail/T25901_exp_fail_1.hs
- + testsuite/tests/rename/should_fail/T25901_exp_fail_1.stderr
- + testsuite/tests/rename/should_fail/T25901_exp_fail_1_helper.hs
- + testsuite/tests/rename/should_fail/T25901_exp_fail_2.hs
- + testsuite/tests/rename/should_fail/T25901_exp_fail_2.stderr
- + testsuite/tests/rename/should_fail/T25901_exp_fail_2_helper.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_5.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_5.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_6.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hq_fail_6.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_hu_fail_4.hs
- + testsuite/tests/rename/should_fail/T25901_imp_hu_fail_4.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_2.hs
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_2.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_3.hs
- + testsuite/tests/rename/should_fail/T25901_imp_sq_fail_3.stderr
- + testsuite/tests/rename/should_fail/T25901_imp_su_fail_1.hs
- + testsuite/tests/rename/should_fail/T25901_imp_su_fail_1.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rts/KeepCafsBase.hs
- testsuite/tests/rts/all.T
- + testsuite/tests/simplCore/should_compile/T26588.hs
- + testsuite/tests/simplCore/should_compile/T26589.hs
- testsuite/tests/simplCore/should_compile/T8331.stderr
- testsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/unboxedsums/UbxSumUnpackedSize.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dodgy.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dodgy.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_1.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_1.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_2.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_2.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_3.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_3.stderr
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_4.hs
- + testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_4.stderr
- + testsuite/tests/warnings/should_compile/T25901_helper_1.hs
- + testsuite/tests/warnings/should_compile/T25901_helper_2.hs
- + testsuite/tests/warnings/should_compile/T25901_helper_3.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_1.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_1.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_2.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_dodgy_2.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_1.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_1.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_2.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_2.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_3.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_3.stderr
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_4.hs
- + testsuite/tests/warnings/should_compile/T25901_imp_unused_4.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Main.hs
- utils/check-exact/Transform.hs
- utils/check-exact/Utils.hs
- utils/ghc-pkg/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
- utils/haddock/haddock-test/src/Test/Haddock.hs
- utils/hpc
- utils/hsc2hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ee11c6936ff74dee8a880c45c48f5…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ee11c6936ff74dee8a880c45c48f5…
You're receiving this email because of your account on gitlab.haskell.org.
1
0