Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC
Commits:
9f4b5aab by Alan Zimmerman at 2025-06-21T13:20:54+01:00
Some cleanup
- - - - -
4 changed files:
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PreProcess.hs
- compiler/GHC/Parser/PreProcess/State.hs
- utils/check-cpp/PreProcess.hs
Changes:
=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -59,7 +59,6 @@ module GHC.Parser.Lexer (
Token(..), lexer, lexerDbg,
ParserOpts(..), mkParserOpts,
PState (..), initParserState, initPragState,
- PSavedAlrState(..), getAlrState, setAlrState,
startSkipping, stopSkipping,
P(..), ParseResult(POk, PFailed),
allocateComments, allocatePriorComments, allocateFinalComments,
@@ -273,7 +272,6 @@ $tab { warnTab }
-- set.
"{-" / { isNormalComment } { nested_comment }
--- "/*" / { ifExtension GhcCppBit } { cpp_comment }
-- Single-line comments are a bit tricky. Haskell 98 says that two or
-- more dashes followed by a symbol should be parsed as a varsym, so we
@@ -1351,6 +1349,7 @@ hopefully_open_brace :: Action p
hopefully_open_brace span buf len buf2
= do relaxed <- getBit RelaxedLayoutBit
ctx <- getContext
+ -- See Note [GHC_CPP saved offset]
offset <- getOffset
let
isOK = relaxed ||
@@ -1592,15 +1591,6 @@ nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLe
dropTrailingDec "-}" = ""
dropTrailingDec (x:xs) = x:dropTrailingDec xs
-cpp_comment :: Action p
-cpp_comment span buf len _buf2 = {-# SCC "cpp_comment" #-} do
- l <- getLastLocIncludingComments
- let endComment input (L _ comment) = commentEnd lexToken input (Nothing, ITblockComment comment l) buf span
- input <- getInput
- -- Include decorator in comment
- let start_decorator = reverse $ lexemeToString buf len
- cpp_comment_logic endComment start_decorator input span
-
{-# INLINE nested_comment_logic #-}
-- | Includes the trailing '-}' decorators
-- drop the last two elements with the callback if you don't want them to be included
@@ -1635,31 +1625,6 @@ nested_comment_logic endComment commentAcc input span = go commentAcc (1::Int) i
Just (_,_) -> go ('\n':commentAcc) n input
Just (c,input) -> go (c:commentAcc) n input
-{-# INLINE cpp_comment_logic #-}
--- | Includes the trailing '*/' decorators
--- drop the last two elements with the callback if you don't want them to be included
-cpp_comment_logic
- :: (AlexInput -> Located String -> P p (PsLocated Token)) -- ^ Continuation that gets the rest of the input and the lexed comment
- -> String -- ^ starting value for accumulator (reversed) - When we want to include a decorator '/*' in the comment
- -> AlexInput
- -> PsSpan
- -> P p (PsLocated Token)
-cpp_comment_logic endComment commentAcc input span = go commentAcc (1::Int) input
- where
- go commentAcc 0 input@(AI end_loc _) = do
- let comment = reverse commentAcc
- cspan = mkSrcSpanPs $ mkPsSpan (psSpanStart span) end_loc
- lcomment = L cspan comment
- endComment input lcomment
- go commentAcc n input = case alexGetChar' input of
- Nothing -> errBrace input (psRealSpan span)
- Just ('*',input) -> case alexGetChar' input of
- Nothing -> errBrace input (psRealSpan span)
- Just ('/',input) -> go ('/':'*':commentAcc) (n-1) input -- '/'
- Just (_,_) -> go ('*':commentAcc) n input
- Just (c,input) -> go (c:commentAcc) n input
-
-
ghcCppSet :: P p Bool
ghcCppSet = do
exts <- getExts
@@ -1775,6 +1740,7 @@ linePrag span buf len buf2 = do
usePosPrags <- getBit UsePosPragsBit
if usePosPrags
then begin line_prag2 span buf len buf2
+ -- TODO:AZ: should we make this test if GhcCpp is active, and maybe do the old
-- else let !src = lexemeToFastString buf len
-- in return (L span (ITline_prag (SourceText src)))
else nested_comment span buf len buf2
@@ -2166,6 +2132,7 @@ do_bol span _str _len _buf2 = do
-- See Note [Nested comment line pragmas]
b <- getBit InNestedCommentBit
if b then return (L span ITcomment_line_prag) else do
+ -- See Note [GHC_CPP saved offset]
resetOffset
(pos, gen_semic) <- getOffside
case pos of
@@ -2216,6 +2183,7 @@ maybe_layout t = do -- If the alternative layout rule is enabled then
new_layout_context :: Bool -> Bool -> Token -> Action p
new_layout_context strict gen_semic tok span _buf len _buf2 = do
_ <- popLexState
+ -- See Note [GHC_CPP saved offset]
current_col <- getOffset
let offset = current_col - len
ctx <- getContext
@@ -2670,6 +2638,7 @@ data PState a = PState {
pp :: !a,
-- If a CPP directive occurs in the layout context, we need to
-- store the prior column so any alr processing can continue.
+ -- See Note [GHC_CPP saved offset]
pp_last_col :: !(Maybe Int)
}
-- last_loc and last_len are used when generating error messages,
@@ -2684,32 +2653,6 @@ data PState a = PState {
-- of the action, it is the *current* token. Do I understand
-- correctly?
-data PSavedAlrState = PSavedAlrState {
- -- s_warnings :: Messages PsMessage,
- -- s_errors :: Messages PsMessage,
- s_lex_state :: [Int],
- s_context :: [LayoutContext],
- s_alr_pending_implicit_tokens :: [PsLocated Token],
- s_alr_next_token :: Maybe (PsLocated Token),
- s_alr_last_loc :: PsSpan,
- s_alr_context :: [ALRContext],
- s_alr_expecting_ocurly :: Maybe ALRLayout,
- s_alr_justClosedExplicitLetBlock :: Bool,
- s_last_col :: Int
- }
-
-
--- -- | Use for emulating (limited) CPP preprocessing in GHC.
--- -- TODO: move this into PreProcess, and make a param on PState
--- data PpState = PpState {
--- pp_defines :: !(Map String [String]),
--- pp_continuation :: ![Located Token],
--- -- pp_context :: ![PpContext],
--- pp_context :: ![Token], -- What preprocessor directive we are currently processing
--- pp_accepting :: !Bool
--- }
--- deriving (Show)
-
data PpContext = PpContextIf [Located Token]
deriving (Show)
@@ -2825,7 +2768,7 @@ getLastBufCur = P $ \s@(PState { last_buf_cur = last_buf_cur }) -> POk s last_bu
getLastLen :: P p Int
getLastLen = P $ \s@(PState { last_len = last_len }) -> POk s last_len
--- see Note [TBD]
+-- See Note [GHC_CPP saved offset]
getOffset :: P p Int
getOffset = P $ \s@(PState { pp_last_col = last_col,
loc = l}) ->
@@ -2835,74 +2778,55 @@ getOffset = P $ \s@(PState { pp_last_col = last_col,
-- (fromMaybe (srcLocCol (psRealLoc l)) last_col)
in POk s { pp_last_col = Nothing} offset
+-- See Note [GHC_CPP saved offset]
resetOffset :: P p ()
resetOffset = P $ \s -> POk s { pp_last_col = Nothing} ()
+{- Note [GHC_CPP saved offset]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The layout processing machinery examines the offset of the previous
+line when doing its calculations.
+
+When GHC_CPP is used, a set of CPP directives may ignore some number
+of preceding lines, each of which has a different offset.
+
+We deal with this as follows
+
+- When we start skipping lines due to CPP we store the offset of the
+ line before the CPP directive
+- We explicitly ask for the offset using `getOffset` when doing layout
+ calculations
+- If there is a stored offset, we use that instead of the prior line
+ offset
+
+-}
+
startSkipping :: P p ()
startSkipping = do
pushLexState skipping
-- pushLexState (trace ("startSkipping:" ++ show skipping) skipping)
-stopSkipping :: P p Int
+stopSkipping :: P p ()
stopSkipping = do
- -- popLexState
- ret <- popLexState
+ _ <- popLexState
-- We just processed a CPP directive, which included a trailing newline.
-- To properly sync up, we now need to ensure that `do_bol` processing occurs.
- -- But this call does not emit a token.
- -- Maybe it should be an argument to lexToken instead?
- -- Alternatively, push the input location to the previous char.
- AI ps buf <- getInput
- last_buf_cur <- getLastBufCur
- last_loc <- getLastLoc
+ -- But this call does not emit a token, so we instead
+ -- change the input location to the previous char, the newline
+ AI _ps buf <- getInput
last_tk <- getLastTk
case last_tk of
Strict.Just (L l _) -> do
let ps' = PsLoc (realSrcSpanEnd (psRealSpan l)) (bufSpanEnd (psBufSpan l))
let cur' = (cur buf) - 1
- -- let cur' = trace ("stopSkipping:(cur',ps'):" ++ show (cur'',ps')) cur''
setInput (AI ps' (buf { cur = cur'}))
_ -> return ()
- -- return $ trace ("stopSkipping: (ps, cur buf, last_loc, last_buf_cur, last_tk):" ++ show (ps, cur buf, last_loc, last_buf_cur, last_tk)) ret
- return ret
-- old <- popLexState
-- return (trace ("stopSkipping:" ++ show old) old)
-getAlrState :: P p PSavedAlrState
-getAlrState = P $ \s@(PState {loc=l}) -> POk s
- PSavedAlrState {
- -- s_warnings = warnings s,
- -- s_errors = errors s,
- -- s_lex_state = lex_state s,
- s_lex_state = lex_state s,
- s_context = context s,
- s_alr_pending_implicit_tokens = alr_pending_implicit_tokens s,
- s_alr_next_token = alr_next_token s,
- s_alr_last_loc = alr_last_loc s,
- s_alr_context = alr_context s,
- s_alr_expecting_ocurly = alr_expecting_ocurly s,
- s_alr_justClosedExplicitLetBlock = alr_justClosedExplicitLetBlock s,
- s_last_col = srcLocCol (psRealLoc l)
- }
-
-setAlrState :: PSavedAlrState -> P p ()
-setAlrState ss = P $ \s -> POk s {
- -- errors = s_errors ss,
- -- warnings = s_warnings ss,
- lex_state = s_lex_state ss,
- context = s_context ss,
- alr_pending_implicit_tokens = s_alr_pending_implicit_tokens ss,
- alr_next_token = s_alr_next_token ss,
- alr_last_loc = s_alr_last_loc ss,
- alr_context = s_alr_context ss,
- alr_expecting_ocurly = s_alr_expecting_ocurly ss,
- alr_justClosedExplicitLetBlock = s_alr_justClosedExplicitLetBlock ss,
- pp_last_col = Just (s_last_col ss)
- } ()
-
-
{-# INLINE alexGetChar' #-}
-- This version does not squash unicode characters, it is used when
@@ -3199,6 +3123,7 @@ disableHaddock opts = upd_bitmap (xunset HaddockBit)
where
upd_bitmap f = opts { pExtsBitmap = f (pExtsBitmap opts) }
+-- TODO:AZ check which of these are actually needed,
enableGhcCpp :: ParserOpts -> ParserOpts
enableGhcCpp = enableExtBit GhcCppBit
@@ -3881,8 +3806,6 @@ warn_unknown_prag prags span buf len buf2 = do
%************************************************************************
-}
--- TODO:AZ: we should have only mkParensEpToks. Delete mkParensEpAnn, mkParensLocs
-
-- |Given a 'RealSrcSpan' that surrounds a 'HsPar' or 'HsParTy', generate
-- 'EpToken' values for the opening and closing bordering on the start
-- and end of the span
=====================================
compiler/GHC/Parser/PreProcess.hs
=====================================
@@ -14,8 +14,8 @@ module GHC.Parser.PreProcess (
) where
import Data.List (intercalate, sortBy)
-import Data.Maybe (fromMaybe, listToMaybe)
import Data.Map qualified as Map
+import Data.Maybe (fromMaybe, listToMaybe)
import Debug.Trace (trace)
import GHC.Data.FastString
import GHC.Data.Strict qualified as Strict
@@ -23,6 +23,7 @@ import GHC.Data.StringBuffer
import GHC.Driver.DynFlags (DynFlags, xopt)
import GHC.LanguageExtensions qualified as LangExt
import GHC.Parser.Errors.Ppr ()
+import GHC.Parser.Errors.Types (PsMessage (PsErrGhcCpp))
import GHC.Parser.Lexer (P (..), PState (..), ParseResult (..), Token (..))
import GHC.Parser.Lexer qualified as Lexer
import GHC.Parser.PreProcess.Macro
@@ -34,7 +35,6 @@ import GHC.Types.SrcLoc
import GHC.Utils.Error
import GHC.Utils.Outputable (text)
import GHC.Utils.Panic.Plain (panic)
-import GHC.Parser.Errors.Types (PsMessage(PsErrGhcCpp))
-- ---------------------------------------------------------------------
@@ -42,9 +42,10 @@ dumpGhcCpp :: DynFlags -> PState PpState -> SDoc
dumpGhcCpp dflags pst = output
where
ghc_cpp_enabled = xopt LangExt.GhcCpp dflags
- output = if ghc_cpp_enabled
- then text $ sepa ++ defines ++ sepa ++ final ++ sepa
- else text "GHC_CPP not enabled"
+ output =
+ if ghc_cpp_enabled
+ then text $ sepa ++ defines ++ sepa ++ final ++ sepa
+ else text "GHC_CPP not enabled"
-- Note: pst is the state /before/ the parser runs, so we can use it to lex.
(pst_final, bare_toks) = lexAll pst
comments = reverse (Lexer.comment_q pst_final)
@@ -76,6 +77,7 @@ renderCombinedToks toks = showCppTokenStream toks
-- ---------------------------------------------------------------------
-- addSourceToTokens copied here to unbreak an import loop.
-- It should probably move somewhere else
+-- TODO: We should be able to do away with this once #26095 is done
{- | Given a source location and a StringBuffer corresponding to this
location, return a rich token stream with the source associated to the
@@ -105,7 +107,8 @@ addSourceToTokens loc0 buf0 (t@(L sp _) : ts) =
-- ---------------------------------------------------------------------
--- Tweaked from showRichTokenStream
+-- Tweaked from showRichTokenStream, to add markers per line if it is
+-- currently active or not
showCppTokenStream :: [(Located Token, String)] -> String
showCppTokenStream ts0 = go startLoc ts0 ""
where
@@ -196,7 +199,7 @@ ppLexer queueComments cont =
ppLexer queueComments cont
in
case tk of
- -- case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of
+ -- case (trace ("M.ppLexer:tk=" ++ show (unLoc tk)) tk) of
L _ ITeof -> do
mInp <- popIncludeLoc
case mInp of
@@ -219,13 +222,11 @@ ppLexer queueComments cont =
case mdump of
Just dump ->
-- We have a dump of the state, put it into an ignored token
+ -- AZ: TODO: is this actually useful?
contIgnoreTok (L l (ITcpp continuation (appendFS s (fsLit dump)) sp))
Nothing -> contIgnoreTok tk
else contInner tk
L _ (ITcppIgnored _ _) -> contIgnoreTok tk
- L _ (ITline_prag _) -> do
- setInLinePragma True
- contIgnoreTok tk
_ -> do
state <- getCppState
inLinePragma <- getInLinePragma
@@ -253,7 +254,7 @@ processCppToks fs = do
-- Combine any prior continuation tokens
cs <- popContinuation
let loc = combineLocs fs (fromMaybe fs (listToMaybe cs))
- processCpp loc (concat $ reverse $ map get (fs:cs))
+ processCpp loc (concat $ reverse $ map get (fs : cs))
processCpp :: SrcSpan -> String -> PP (Maybe String)
processCpp loc s = do
@@ -262,13 +263,11 @@ processCpp loc s = do
then return (Just "\ndumped state\n")
else do
case directive of
- Left err -> Lexer.addError $ mkPlainErrorMsgEnvelope loc $ PsErrGhcCpp (text err)
+ Left err -> Lexer.addError $ mkPlainErrorMsgEnvelope loc $ PsErrGhcCpp (text err)
Right (CppInclude filename) -> do
ppInclude filename
- Right (CppDefine name args def) -> do
- ppDefine (MacroName name args) def
- Right (CppUndef name) -> do
- ppUndef name
+ Right (CppDefine name args def) -> ppDefine (MacroName name args) def
+ Right (CppUndef name) -> ppUndef name
Right (CppIf cond) -> do
val <- cppCond loc cond
ar <- pushAccepting val
=====================================
compiler/GHC/Parser/PreProcess/State.hs
=====================================
@@ -71,7 +71,6 @@ initPpState =
, pp_continuation = []
, pp_defines = Map.empty
, pp_scope = (PpScope True PpNoGroup) :| []
- , pp_alr_state = Nothing
, pp_in_line_pragma = False
}
@@ -81,7 +80,6 @@ data PpState = PpState
, pp_continuation :: ![Located Lexer.Token]
, pp_defines :: !MacroDefines
, pp_scope :: !(NonEmpty PpScope)
- , pp_alr_state :: Maybe Lexer.PSavedAlrState
, pp_in_line_pragma :: !Bool
}
=====================================
utils/check-cpp/PreProcess.hs
=====================================
@@ -329,15 +329,8 @@ processCpp loc s = do
acceptStateChange :: AcceptingResult -> PP ()
acceptStateChange ArNoChange = return ()
acceptStateChange ArNowIgnoring = do
- -- alr <- Lexer.getAlrState
- -- s <- getPpState
- -- let s = trace ("acceptStateChange:ArNowIgnoring") s'
- -- setPpState (s { pp_alr_state = Just alr})
Lexer.startSkipping
acceptStateChange ArNowAccepting = do
- -- s <- getPpState
- -- let s = trace ("acceptStateChange:ArNowAccepting") s'
- -- mapM_ Lexer.setAlrState (pp_alr_state s)
_ <- Lexer.stopSkipping
return ()
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f4b5aabeeeabc3134e5464f8ecb707…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f4b5aabeeeabc3134e5464f8ecb707…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Teo Camarasu pushed new branch wip/teo/th-changelog at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/teo/th-changelog
You're receiving this email because of your account on gitlab.haskell.org.
1
0

21 Jun '25
Teo Camarasu pushed new branch wip/teo/allow-newer-ghc-paths at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/teo/allow-newer-ghc-paths
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/az/ghc-cpp] 134 commits: Deprecate -Wdata-kinds-tc, make DataKinds issues in typechecker become errors
by Alan Zimmerman (@alanz) 21 Jun '25
by Alan Zimmerman (@alanz) 21 Jun '25
21 Jun '25
Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC
Commits:
d3e60e97 by Ryan Scott at 2025-06-18T22:29:21-04:00
Deprecate -Wdata-kinds-tc, make DataKinds issues in typechecker become errors
!11314 introduced the `-Wdata-kinds-tc` warning as part of a fix for #22141.
This was a temporary stopgap measure to allow users who were accidentally
relying on code which needed the `DataKinds` extension in order to typecheck
without having to explicitly enable the extension.
Now that some amount of time has passed, this patch deprecates
`-Wdata-kinds-tc` and upgrades any `DataKinds`-related issues in the
typechecker (which were previously warnings) into errors.
- - - - -
fd5b5177 by Ryan Hendrickson at 2025-06-18T22:30:06-04:00
haddock: Add redact-type-synonyms pragma
`{-# OPTIONS_HADDOCK redact-type-synonyms #-}` pragma will hide the RHS
of type synonyms, and display the result kind instead, if the RHS
contains any unexported types.
- - - - -
15b2b2ec by Alan Zimmerman at 2025-06-19T19:35:02+01:00
GHC-CPP: first rough proof of concept
Processes
#define FOO
#ifdef FOO
x = 1
#endif
Into
[ITcppIgnored [L loc ITcppDefine]
,ITcppIgnored [L loc ITcppIfdef]
,ITvarid "x"
,ITequal
,ITinteger (IL {il_text = SourceText "1", il_neg = False, il_value = 1})
,ITcppIgnored [L loc ITcppEndif]
,ITeof]
In time, ITcppIgnored will be pushed into a comment
- - - - -
8a890112 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Tidy up before re-visiting the continuation mechanic
- - - - -
b81a1ae0 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Switch preprocessor to continuation passing style
Proof of concept, needs tidying up
- - - - -
cfe778e2 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Small cleanup
- - - - -
56dde4c8 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Get rid of some cruft
- - - - -
19be2264 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Starting to integrate.
Need to get the pragma recognised and set
- - - - -
9d65fbb9 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Make cppTokens extend to end of line, and process CPP comments
- - - - -
aacef8f5 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Remove unused ITcppDefined
- - - - -
9f54aa10 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Allow spaces between # and keyword for preprocessor directive
- - - - -
841e8b19 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Process CPP continuation lines
They are emited as separate ITcppContinue tokens.
Perhaps the processing should be more like a comment, and keep on
going to the end.
BUT, the last line needs to be slurped as a whole.
- - - - -
d0a141b9 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Accumulate CPP continuations, process when ready
Can be simplified further, we only need one CPP token
- - - - -
12c0689b by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Simplify Lexer interface. Only ITcpp
We transfer directive lines through it, then parse them from scratch
in the preprocessor.
- - - - -
30cd0529 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Deal with directive on last line, with no trailing \n
- - - - -
e2d20617 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Start parsing and processing the directives
- - - - -
74955b8e by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Prepare for processing include files
- - - - -
6c2f7197 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Move PpState into PreProcess
And initParserState, initPragState too
- - - - -
b112d95c by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Process nested include files
Also move PpState out of Lexer.x, so it is easy to evolve it in a ghci
session, loading utils/check-cpp/Main.hs
- - - - -
c62fbc6d by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Split into separate files
- - - - -
5e9b65b6 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Starting on expression parser.
But it hangs. Time for Text.Parsec.Expr
- - - - -
e7233f54 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Start integrating the ghc-cpp work
From https://github.com/alanz/ghc-cpp
- - - - -
d44f73a2 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
WIP
- - - - -
3524ce86 by Alan Zimmerman at 2025-06-19T19:35:02+01:00
Fixup after rebase
- - - - -
7a0bfc0a by Alan Zimmerman at 2025-06-19T19:35:03+01:00
WIP
- - - - -
b247de57 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Fixup after rebase, including all tests pass
- - - - -
186c6054 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Change pragma usage to GHC_CPP from GhcCPP
- - - - -
b7ed58f2 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Some comments
- - - - -
0a7d82d3 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Reformat
- - - - -
0c126cd1 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Delete unused file
- - - - -
741b5935 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Rename module Parse to ParsePP
- - - - -
db9b5584 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Clarify naming in the parser
- - - - -
ed0e5a41 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
WIP. Switching to alex/happy to be able to work in-tree
Since Parsec is not available
- - - - -
e567da0c by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Layering is now correct
- GHC lexer, emits CPP tokens
- accumulated in Preprocessor state
- Lexed by CPP lexer, CPP command extracted, tokens concated with
spaces (to get rid of token pasting via comments)
- if directive lexed and parsed by CPP lexer/parser, and evaluated
- - - - -
468cda2a by Alan Zimmerman at 2025-06-19T19:35:03+01:00
First example working
Loading Example1.hs into ghci, getting the right results
```
{-# LANGUAGE GHC_CPP #-}
module Example1 where
y = 3
x =
"hello"
"bye now"
foo = putStrLn x
```
- - - - -
6bbc63fb by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Rebase, and all tests pass except whitespace for generated parser
- - - - -
a4ec35ca by Alan Zimmerman at 2025-06-19T19:35:03+01:00
More plumbing. Ready for testing tomorrow.
- - - - -
91c2d89f by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Proress. Renamed module State from Types
And at first blush it seems to handle preprocessor scopes properly.
- - - - -
0c944603 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Insert basic GHC version macros into parser
__GLASGOW_HASKELL__
__GLASGOW_HASKELL_FULL_VERSION__
__GLASGOW_HASKELL_PATCHLEVEL1__
__GLASGOW_HASKELL_PATCHLEVEL2__
- - - - -
668d141e by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Re-sync check-cpp for easy ghci work
- - - - -
4f5b0d0b by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Get rid of warnings
- - - - -
7fdc08bd by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Rework macro processing, in check-cpp
Macros kept at the top level, looked up via name, multiple arity
versions per name can be stored
- - - - -
07814b89 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
WIP. Can crack arguments for #define
Next step it to crack out args in an expansion
- - - - -
53e55437 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
WIP on arg parsing.
- - - - -
8c04ddfd by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Progress. Still screwing up nested parens.
- - - - -
8e594a84 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Seems to work, but has redundant code
- - - - -
cc21e1d4 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Remove redundant code
- - - - -
6620f57c by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Reformat
- - - - -
694c05ef by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Expand args, single pass
Still need to repeat until fixpoint
- - - - -
a043620f by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Fixed point expansion
- - - - -
750c694f by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Sync the playground to compiler
- - - - -
6c8750c2 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Working on dumping the GHC_CPP result
But We need to keep the BufSpan in a comment
- - - - -
bdb8adf2 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Keep BufSpan in queued comments in GHC.Parser.Lexer
- - - - -
3ae1d536 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Getting close to being able to print the combined tokens
showing what is in and what is out
- - - - -
accff1b5 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
First implementation of dumpGhcCpp.
Example output
First dumps all macros in the state, then the source, showing which
lines are in and which are out
------------------------------
- |#define FOO(A,B) A + B
- |#define FOO(A,B,C) A + B + C
- |#if FOO(1,FOO(3,4)) == 8
- |-- a comment
|x = 1
- |#else
- |x = 5
- |#endif
- - - - -
8b9bf22a by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Clean up a bit
- - - - -
2f6ecade by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Add -ddump-ghc-cpp option and a test based on it
- - - - -
365aa02d by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Restore Lexer.x rules, we need them for continuation lines
- - - - -
0f6dfae8 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Lexer.x: trying to sort out the span for continuations
- We need to match on \n at the end of the line
- We cannot simply back up for it
- - - - -
9f6aec58 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Inserts predefined macros. But does not dump properly
Because the cpp tokens have a trailing newline
- - - - -
829f75e2 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Remove unnecessary LExer rules
We *need* the ones that explicitly match to the end of the line.
- - - - -
501a2caf by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Generate correct span for ITcpp
Dump now works, except we do not render trailing `\` for continuation
lines. This is good enough for use in test output.
- - - - -
db23d6e9 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Reduce duplication in lexer
- - - - -
047e48f5 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Tweaks
- - - - -
37b47da0 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Insert min_version predefined macros into state
The mechanism now works. Still need to flesh out the full set.
- - - - -
1e045be7 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Trying my alternative pragma syntax.
It works, but dumpGhcCpp is broken, I suspect from the ITcpp token
span update.
- - - - -
9a61360c by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Pragma extraction now works, with both CPP and GHC_CPP
For the following
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 913
{-# LANGUAGE GHC_CPP #-}
#endif
We will enable GHC_CPP only
- - - - -
4f8555c7 by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Remove some tracing
- - - - -
8a68e6dc by Alan Zimmerman at 2025-06-19T19:35:03+01:00
Fix test exes for changes
- - - - -
12177e13 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
For GHC_CPP tests, normalise config-time-based macros
- - - - -
d442984b by Alan Zimmerman at 2025-06-19T19:35:04+01:00
WIP
- - - - -
5cbb9087 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
WIP again. What is wrong?
- - - - -
ff468973 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Revert to dynflags for normal not pragma lexing
- - - - -
00a4da95 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Working on getting check-exact to work properly
- - - - -
04c7e601 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Passes CppCommentPlacement test
- - - - -
0a08e51c by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Starting on exact printing with GHC_CPP
While overriding normal CPP
- - - - -
cebb3403 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Correctly store CPP ignored tokens as comments
By populating the lexeme string in it, based on the bufpos
- - - - -
8aa7e52c by Alan Zimmerman at 2025-06-19T19:35:04+01:00
WIP
- - - - -
373b18ab by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Simplifying
- - - - -
eb25bbc6 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Update the active state logic
- - - - -
0c7a106a by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Work the new logic into the mainline code
- - - - -
22726082 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Process `defined` operator
- - - - -
3725a850 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Manage lexer state while skipping tokens
There is very intricate layout-related state used when lexing. If a
CPP directive blanks out some tokens, store this state when the
blanking starts, and restore it when they are no longer being blanked.
- - - - -
15414093 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Track the last token buffer index, for ITCppIgnored
We need to attach the source being skipped in an ITCppIgnored token.
We cannot simply use its BufSpan as an index into the underlying
StringBuffer as it counts unicode chars, not bytes.
So we update the lexer state to store the starting StringBuffer
location for the last token, and use the already-stored length to
extract the correct portion of the StringBuffer being parsed.
- - - - -
337dbc7a by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Process the ! operator in GHC_CPP expressions
- - - - -
b79f9bea by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Predefine a constant when GHC_CPP is being used.
- - - - -
052e64b3 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
WIP
- - - - -
d996722c by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Skip lines directly in the lexer when required
- - - - -
6d5efd6f by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Properly manage location when accepting tokens again
- - - - -
6edf4195 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Seems to be working now, for Example9
- - - - -
2077e54c by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Remove tracing
- - - - -
83a4d5ab by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Fix parsing '*' in block comments
Instead of replacing them with '-'
- - - - -
097b4235 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Keep the trailing backslash in a ITcpp token
- - - - -
e0e1e90f by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Deal with only enabling one section of a group.
A group is an instance of a conditional introduced by
#if/#ifdef/#ifndef,
and ending at the final #endif, including intermediate #elsif sections
- - - - -
7151fd24 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Replace remaining identifiers with 0 when evaluating
As per the spec
- - - - -
49cfb7a3 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Snapshot before rebase
- - - - -
4cfce858 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Skip non-processed lines starting with #
- - - - -
c706f25d by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Export generateMacros so we can use it in ghc-exactprint
- - - - -
89b39f49 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Fix rebase
- - - - -
2a346936 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Expose initParserStateWithMacrosString
- - - - -
f12c44db by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Fix buggy lexer cppSkip
It was skipping all lines, not just ones prefixed by #
- - - - -
5f84c0db by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Fix evaluation of && to use the correct operator
- - - - -
2d8bedc7 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Deal with closing #-} at the start of a line
- - - - -
555b7a83 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Add the MIN_VERSION_GLASGOW_HASKELL predefined macro
- - - - -
ba80b032 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Include MIN_VERSION_GLASGOW_HASKELL in GhcCpp01.stderr
- - - - -
edf528f7 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Use a strict map for macro defines
- - - - -
c28cd1b7 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Process TIdentifierLParen
Which only matters at the start of #define
- - - - -
0516c631 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Do not provide TIdentifierLParen paren twice
- - - - -
24e4d45d by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Handle whitespace between identifier and '(' for directive only
- - - - -
4de7275c by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Expose some Lexer bitmap manipulation helpers
- - - - -
6d12ec40 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Deal with line pragmas as tokens
Blows up for dumpGhcCpp though
- - - - -
c682be7a by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Allow strings delimited by a single quote too
- - - - -
1a549ee1 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Allow leading whitespace on cpp directives
As per https://timsong-cpp.github.io/cppwp/n4140/cpp#1
- - - - -
4d2d4de1 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Implement GHC_CPP undef
- - - - -
9533c2d7 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Sort out expansion of no-arg macros, in a context with args
And make the expansion bottom out, in the case of recursion
- - - - -
dbcbb002 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Fix GhcCpp01 test
The LINE pragma stuff works in ghc-exactprint when specifically
setting flag to emit ITline_pragma tokens
- - - - -
8e460807 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Process comments in CPP directives
- - - - -
7103a6b2 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Correctly lex pragmas with finel #-} on a newline
- - - - -
830c79e0 by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Do not process CPP-style comments
- - - - -
37a486ec by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Allow cpp-style comments when GHC_CPP enabled
- - - - -
a8a1722b by Alan Zimmerman at 2025-06-19T19:35:04+01:00
Return other pragmas as cpp ignored when GHC_CPP active
- - - - -
789233df by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Fix exactprinting default decl
- - - - -
b3ccee8b by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Reorganise getOptionsFromFile for use in ghc-exactprint
We want to be able to inject predefined macro definitions into the
parser preprocessor state for when we do a hackage roundtrip.
- - - - -
6b84f415 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Tweak testing
- - - - -
a8fcfa4a by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Only allow unknown cpp pragmas with # in left margin
- - - - -
ac95dd60 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Require # against left margin for all GHC_CPP directives
- - - - -
8947e929 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Fix CPP directives appearing in pragmas
And add a test for error reporting for missing `#if`
- - - - -
3c073ceb by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Starting to report GHC_CPP errors using GHC machinery
- - - - -
1ee27ed3 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
More GHC_CPP diagnostic results
- - - - -
f70203f8 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
WIP on converting error calls to GHC diagnostics in GHC_CPP
- - - - -
b3f8401d by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Working on CPP diagnostic reporting
- - - - -
882e38a6 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Tweak some tests/lint warnings
- - - - -
995e97e4 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
More error reporting in Macro
- - - - -
f0477b99 by Alan Zimmerman at 2025-06-19T19:35:05+01:00
Some cleanups
- - - - -
128 changed files:
- compiler/GHC.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Parser/Monad.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Config/Parser.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Parser.hs-boot
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Parser/Header.hs
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- + compiler/GHC/Parser/PreProcess.hs
- + compiler/GHC/Parser/PreProcess/Eval.hs
- + compiler/GHC/Parser/PreProcess/Lexer.x
- + compiler/GHC/Parser/PreProcess/Macro.hs
- + compiler/GHC/Parser/PreProcess/ParsePP.hs
- + compiler/GHC/Parser/PreProcess/Parser.y
- + compiler/GHC/Parser/PreProcess/ParserM.hs
- + compiler/GHC/Parser/PreProcess/State.hs
- compiler/GHC/Parser/Utils.hs
- compiler/GHC/SysTools/Cpp.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/ghc.cabal.in
- docs/users_guide/9.14.1-notes.rst
- docs/users_guide/debugging.rst
- docs/users_guide/using-warnings.rst
- ghc/GHCi/UI.hs
- hadrian/src/Rules/SourceDist.hs
- hadrian/stack.yaml.lock
- libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/driver/T4437.hs
- testsuite/tests/ghc-api/T11579.hs
- + testsuite/tests/ghc-cpp/GhcCpp01.hs
- + testsuite/tests/ghc-cpp/GhcCpp01.stderr
- + testsuite/tests/ghc-cpp/GhcCpp02.hs
- + testsuite/tests/ghc-cpp/GhcCpp02.stderr
- + testsuite/tests/ghc-cpp/all.T
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- + testsuite/tests/printer/CppCommentPlacement.hs
- + testsuite/tests/typecheck/should_compile/T20873c.hs
- − testsuite/tests/typecheck/should_compile/T22141a.stderr
- − testsuite/tests/typecheck/should_compile/T22141b.stderr
- − testsuite/tests/typecheck/should_compile/T22141c.stderr
- − testsuite/tests/typecheck/should_compile/T22141d.stderr
- − testsuite/tests/typecheck/should_compile/T22141e.stderr
- testsuite/tests/typecheck/should_compile/all.T
- − testsuite/tests/typecheck/should_fail/T20873c.hs
- − testsuite/tests/typecheck/should_fail/T20873c.stderr
- testsuite/tests/typecheck/should_compile/T22141a.hs → testsuite/tests/typecheck/should_fail/T22141a.hs
- testsuite/tests/typecheck/should_fail/T22141a.stderr
- testsuite/tests/typecheck/should_compile/T22141b.hs → testsuite/tests/typecheck/should_fail/T22141b.hs
- testsuite/tests/typecheck/should_fail/T22141b.stderr
- testsuite/tests/typecheck/should_compile/T22141c.hs → testsuite/tests/typecheck/should_fail/T22141c.hs
- testsuite/tests/typecheck/should_fail/T22141c.stderr
- testsuite/tests/typecheck/should_compile/T22141d.hs → testsuite/tests/typecheck/should_fail/T22141d.hs
- testsuite/tests/typecheck/should_fail/T22141d.stderr
- testsuite/tests/typecheck/should_compile/T22141e.hs → testsuite/tests/typecheck/should_fail/T22141e.hs
- testsuite/tests/typecheck/should_fail/T22141e.stderr
- testsuite/tests/typecheck/should_compile/T22141e_Aux.hs → testsuite/tests/typecheck/should_fail/T22141e_Aux.hs
- testsuite/tests/typecheck/should_fail/all.T
- testsuite/tests/vdq-rta/should_fail/T23739_fail_case.hs
- testsuite/tests/vdq-rta/should_fail/T23739_fail_case.stderr
- + utils/check-cpp/.ghci
- + utils/check-cpp/.gitignore
- + utils/check-cpp/Eval.hs
- + utils/check-cpp/Example1.hs
- + utils/check-cpp/Example10.hs
- + utils/check-cpp/Example11.hs
- + utils/check-cpp/Example12.hs
- + utils/check-cpp/Example13.hs
- + utils/check-cpp/Example2.hs
- + utils/check-cpp/Example3.hs
- + utils/check-cpp/Example4.hs
- + utils/check-cpp/Example5.hs
- + utils/check-cpp/Example6.hs
- + utils/check-cpp/Example7.hs
- + utils/check-cpp/Example8.hs
- + utils/check-cpp/Example9.hs
- + utils/check-cpp/Lexer.x
- + utils/check-cpp/Macro.hs
- + utils/check-cpp/Main.hs
- + utils/check-cpp/ParsePP.hs
- + utils/check-cpp/ParseSimulate.hs
- + utils/check-cpp/Parser.y
- + utils/check-cpp/ParserM.hs
- + utils/check-cpp/PreProcess.hs
- + utils/check-cpp/README.md
- + utils/check-cpp/State.hs
- + utils/check-cpp/run.sh
- utils/check-exact/ExactPrint.hs
- utils/check-exact/Main.hs
- utils/check-exact/Parsers.hs
- utils/check-exact/Preprocess.hs
- utils/check-exact/Utils.hs
- utils/haddock/CHANGES.md
- utils/haddock/doc/cheatsheet/haddocks.md
- utils/haddock/doc/markup.rst
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
- utils/haddock/haddock-api/src/Haddock/Interface.hs
- utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
- utils/haddock/haddock-api/src/Haddock/Parser.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- + utils/haddock/html-test/ref/RedactTypeSynonyms.html
- + utils/haddock/html-test/src/RedactTypeSynonyms.hs
- + utils/haddock/latex-test/ref/RedactTypeSynonyms/RedactTypeSynonyms.tex
- + utils/haddock/latex-test/src/RedactTypeSynonyms/RedactTypeSynonyms.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad20e507e1ddceed3366c8dabc76e3…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad20e507e1ddceed3366c8dabc76e3…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Simon Peyton Jones pushed to branch wip/T26115 at Glasgow Haskell Compiler / GHC
Commits:
714227d7 by Simon Peyton Jones at 2025-06-20T23:50:37+01:00
Wibbles
- - - - -
4 changed files:
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/Tc/Solver/Solve.hs
- testsuite/tests/simplCore/should_compile/T26115.stderr
- testsuite/tests/simplCore/should_compile/all.T
Changes:
=====================================
compiler/GHC/HsToCore/Binds.hs
=====================================
@@ -1168,17 +1168,18 @@ dsSpec_help poly_nm poly_id poly_rhs spec_inl orig_bndrs ds_call
is_local v = v `elemVarSet` locals
rule_bndrs = scopedSort (exprsSomeFreeVarsList is_local rule_lhs_args)
- rn_binds = getRenamings orig_bndrs binds rule_bndrs
- spec_binds = pickSpecBinds is_local (mkVarSet rule_bndrs) binds
+ rn_binds = getRenamings orig_bndrs binds rule_bndrs
+ known_vars = mkVarSet rule_bndrs `extendVarSetList` bindersOfBinds rn_binds
+ picked_binds = pickSpecBinds is_local known_vars binds
-- Make spec_bndrs, the variables to pass to the specialised
-- function, by filtering out the rule_bndrs that aren't needed
- spec_binds_bndr_set = mkVarSet (bindersOfBinds spec_binds)
+ spec_binds_bndr_set = mkVarSet (bindersOfBinds picked_binds)
`minusVarSet` exprsFreeVars (rhssOfBinds rn_binds)
spec_bndrs = filterOut (`elemVarSet` spec_binds_bndr_set) rule_bndrs
- mk_spec_body fn_body = mkLets (rn_binds ++ spec_binds) $
+ mk_spec_body fn_body = mkLets (rn_binds ++ picked_binds) $
mkApps fn_body rule_lhs_args
-- ToDo: not mkCoreApps! That uses exprType on fun which
-- fails in specUnfolding, sigh
@@ -1227,7 +1228,7 @@ dsSpec_help poly_nm poly_id poly_rhs spec_inl orig_bndrs ds_call
, text "rule_bndrs" <+> ppr rule_bndrs
, text "spec_bndrs" <+> ppr spec_bndrs
, text "rn_binds" <+> ppr rn_binds
- , text "spec_binds" <+> ppr spec_binds ]
+ , text "picked_binds" <+> ppr picked_binds ]
; dsWarnOrphanRule rule
=====================================
compiler/GHC/Tc/Solver/Solve.hs
=====================================
@@ -1301,7 +1301,8 @@ tryInertQCs qc
try_inert_qcs :: QCInst -> [QCInst] -> TcS (StopOrContinue ())
try_inert_qcs (QCI { qci_ev = ev_w }) inerts =
case mapMaybe matching_inert inerts of
- [] -> continueWith ()
+ [] -> do { traceTcS "tryInertQCs:nothing" (ppr ev_w $$ ppr inerts)
+ ; continueWith () }
ev_i:_ ->
do { traceTcS "tryInertQCs:KeepInert" (ppr ev_i)
; setEvBindIfWanted ev_w EvCanonical (ctEvTerm ev_i)
@@ -1700,108 +1701,3 @@ runTcPluginSolvers solvers all_cts
addOne (givens, wanteds) (ev,ct) = case ctEvidence ct of
CtGiven {} -> (ct:givens, wanteds)
CtWanted {} -> (givens, (ev,ct):wanteds)
-
---------------------------------------------------------------------------------
-
-{-
--- | If the mode is 'TcSSpecPrag', attempt to fully solve the Wanted
--- constraints that arise from solving 'Ct'.
---
--- If not in 'TcSSpecPrag' mode, simply run 'thing_inside'.
---
--- See Note [TcSSpecPrag] in GHC.Tc.Solver.Monad.
-solveCompletelyIfRequired :: Ct -> TcS (StopOrContinue a) -> TcS (StopOrContinue a)
-solveCompletelyIfRequired ct (TcS thing_inside)
- = TcS $ \ env@(TcSEnv { tcs_ev_binds = outer_ev_binds_var
- , tcs_unified = outer_unified_var
- , tcs_unif_lvl = outer_unif_lvl_var
- , tcs_inerts = outer_inert_var
- , tcs_count = outer_count
- , tcs_mode = mode
- }) ->
- case mode of
- TcSSpecPrag ->
- do { traceTc "solveCompletelyIfRequired {" empty
- -- Create a fresh environment for the inner computation
- ; outer_inerts <- TcM.readTcRef outer_inert_var
- ; let outer_givens = inertGivens outer_inerts
- -- Keep the ambient Given inerts, but drop the Wanteds.
- ; new_inert_var <- TcM.newTcRef outer_givens
- ; new_wl_var <- TcM.newTcRef emptyWorkList
- ; new_ev_binds_var <- TcM.newTcEvBinds
-
- ; let
- inner_env =
- TcSEnv
- -- KEY part: recur with TcSVanilla
- { tcs_mode = TcSVanilla
-
- -- Use new variables for evidence bindings, inerts; and
- -- the work list. We may want to discard all of these if the
- -- inner computation doesn't fully solve all the constraints.
- , tcs_ev_binds = new_ev_binds_var
- , tcs_inerts = new_inert_var
- , tcs_worklist = new_wl_var
-
- -- Inherit the other variables. In particular, inherit the
- -- variables to do with unification, as filling metavariables
- -- is a side-effect that we are not reverting, even when we
- -- discard the result of the inner computation.
- , tcs_unif_lvl = outer_unif_lvl_var
- , tcs_unified = outer_unified_var
- , tcs_count = outer_count
- }
-
- -- Solve the constraint
- ; let wc = emptyWC { wc_simple = unitBag ct }
- ; traceTc "solveCompletelyIfRequired solveWanteds" $
- vcat [ text "ct:" <+> ppr ct
- ]
- ; solved_wc <- unTcS (solveWanteds wc) inner_env
- -- NB: it would probably make more sense to call 'thing_inside',
- -- collecting all constraints that were added to the work list as
- -- a result, and calling 'solveWanteds' on that. This would avoid
- -- restarting from the top of the solver pipeline.
- -- For the time being, we just call 'solveWanteds' on the original
- -- constraint, which is simpler
-
- ; if isSolvedWC solved_wc
- then
- do { -- The constraint was fully solved. Continue with
- -- the inner solver state.
- ; traceTc "solveCompletelyIfRequired: fully solved }" $
- vcat [ text "ct:" <+> ppr ct
- , text "solved_wc:" <+> ppr solved_wc ]
-
- -- Add new evidence bindings to the existing ones
- ; inner_ev_binds <- TcM.getTcEvBindsMap new_ev_binds_var
- ; addTcEvBinds outer_ev_binds_var inner_ev_binds
-
- -- Keep the outer inert set and work list: the inner work
- -- list is empty, and there are no leftover unsolved
- -- Wanteds.
- -- However, we **must not** drop solved implications, due
- -- to Note [Free vars of EvFun] in GHC.Tc.Types.Evidence;
- -- so we re-emit them here.
- ; let re_emit_implic impl = unTcS ( TcS.emitImplication impl ) env
- ; traverse_ re_emit_implic $ wc_impl solved_wc
- ; return $ Stop (ctEvidence ct) (text "Fully solved:" <+> ppr ct)
- }
- else
- do { traceTc "solveCompletelyIfRequired: unsolved }" $
- vcat [ text "ct:" <+> ppr ct
- , text "solved_wc:" <+> ppr solved_wc ]
- -- Failed to fully solve the constraint:
- --
- -- - discard the inner solver state,
- -- - add the original constraint as an inert.
- ; unTcS (updInertIrreds (IrredCt (ctEvidence ct) IrredShapeReason)) env
- -- NB: currently we only call 'solveCompletelyIfRequired'
- -- from 'solveForAll'; so we just stash the unsolved quantified
- -- constraint in the irreds.
-
- ; return $ Stop (ctEvidence ct) (text "Not fully solved; kept as inert:" <+> ppr ct)
- } }
- _notFullySolveMode ->
- thing_inside env
--}
=====================================
testsuite/tests/simplCore/should_compile/T26115.stderr
=====================================
@@ -1,6 +1,6 @@
[GblId[DFunId],
- Unf=DFun: \ (@b_awW) ->
+ Unf=DFun: \ (@b) ->
[GblId[DFunId],
- Unf=DFun: \ (@b_aBU) ->
+ Unf=DFun: \ (@b) ->
[GblId[DFunId],
- Unf=DFun: \ (@p_awR) (@q_awS) (v_B1 :: C p_awR q_awS) ->
+ Unf=DFun: \ (@p) (@q) (v :: C p q) ->
=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -548,6 +548,6 @@ test('T25965', normal, compile, ['-O'])
test('T25703', [grep_errmsg(r'SPEC')], compile, ['-O -fpolymorphic-specialisation -ddump-rule-firings'])
test('T25703a', [grep_errmsg(r'SPEC')], compile, ['-O -fpolymorphic-specialisation -ddump-rule-firings'])
-test('T26115', [grep_errmsg(r'DFun')], compile, ['-O -ddump-simpl'])
+test('T26115', [grep_errmsg(r'DFun')], compile, ['-O -ddump-simpl -dsuppress-uniques'])
test('T26116', normal, compile, ['-O -ddump-rules'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/714227d76e78e5db71cfc808d9e52d7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/714227d76e78e5db71cfc808d9e52d7…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/ghc-9.14] 26 commits: Improve redundant constraints for instance decls
by Ben Gamari (@bgamari) 20 Jun '25
by Ben Gamari (@bgamari) 20 Jun '25
20 Jun '25
Ben Gamari pushed to branch wip/ghc-9.14 at Glasgow Haskell Compiler / GHC
Commits:
19f20861 by Simon Peyton Jones at 2025-06-13T09:51:11-04:00
Improve redundant constraints for instance decls
Addresses #25992, which showed that the default methods
of an instance decl could make GHC fail to report redundant
constraints.
Figuring out how to do this led me to refactor the computation
of redundant constraints. See the entirely rewritten
Note [Tracking redundant constraints]
in GHC.Tc.Solver.Solve
- - - - -
1d02798e by Matthew Pickering at 2025-06-13T09:51:54-04:00
Refactor the treatment of nested Template Haskell splices
* The difference between a normal splice, a quasiquoter and implicit
splice caused by lifting is stored in the AST after renaming.
* Information that the renamer learns about splices is stored in the
relevant splice extension points (XUntypedSpliceExpr, XQuasiQuote).
* Normal splices and quasi quotes record the flavour of splice
(exp/pat/dec etc)
* Implicit lifting stores information about why the lift was attempted,
so if it fails, that can be reported to the user.
* After renaming, the decision taken to attempt to implicitly lift a
variable is stored in the `XXUntypedSplice` extension field in the
`HsImplicitLiftSplice` constructor.
* Since all the information is stored in the AST, in `HsUntypedSplice`,
the type of `PendingRnSplice` now just stores a `HsUntypedSplice`.
* Error messages since the original program can be easily
printed, this is noticeable in the case of implicit lifting.
* The user-written syntax is directly type-checked. Before, some
desugaring took place in the
* Fixes .hie files to work better with nested splices (nested splices
are not indexed)
* The location of the quoter in a quasiquote is now located, so error
messages will precisely point to it (and again, it is indexed by hie
files)
In the future, the typechecked AST should also retain information about
the splices and the specific desugaring being left to the desugarer.
Also, `runRnSplice` should call `tcUntypedSplice`, otherwise the
typechecking logic is duplicated (see the `QQError` and `QQTopError`
tests for a difference caused by this).
- - - - -
f93798ba by Cheng Shao at 2025-06-13T09:52:35-04:00
libffi: update to 3.5.1
Bumps libffi submodule.
- - - - -
c7aa0c10 by Andreas Klebinger at 2025-06-15T05:47:24-04:00
Revert "Specialise: Don't float out constraint components."
This reverts commit c9abb87ccc0c91cd94f42b3e36270158398326ef.
Turns out two benchmarks from #19747 regresses by a factor of 7-8x if
we do not float those out.
- - - - -
fd998679 by Krzysztof Gogolewski at 2025-06-15T05:48:06-04:00
Fix EPT enforcement when mixing unboxed tuples and non-tuples
The code was assuming that an alternative cannot be returning a normal
datacon and an unboxed tuple at the same time. However, as seen in #26107,
this can happen when using a GADT to refine the representation type.
The solution is just to conservatively return TagDunno.
- - - - -
e64b3f16 by ARATA Mizuki at 2025-06-17T10:13:42+09:00
MachRegs.h: Don't define NO_ARG_REGS when a XMM register is defined
On i386, MAX_REAL_VANILLA_REG is 1, but MAX_REAL_XMM_REG is 4.
If we define NO_ARG_REGS on i386, programs that use SIMD vectors may segfault.
Closes #25985
A couple of notes on the BROKEN_TESTS field:
* This fixes the segfault from T25062_V16.
* The failure from T22187_run was fixed in an earlier commit (see #25561),
but BROKEN_TESTS was missed at that time. Now should be a good time to
mark it fixed.
- - - - -
3e7c6b4d by Matthew Pickering at 2025-06-18T15:34:04-04:00
Improve error messages when implicit lifting fails
This patch concerns programs which automatically try to fix level errors
by inserting `Lift`. For example:
```
foo x = [| x |]
~>
foo x = [| $(lift x) |]
```
Before, there were two problems with the message.
1. (#26031), the location of the error was reported as the whole
quotation.
2. (#26035), the message just mentions there is no Lift instance, but
gives no indicate why the user program needed a Lift instance in the
first place.
This problem is especially bad when you disable
`ImplicitStagePersistence`, so you just end up with a confusing "No
instance for" message rather than an error message about levels
This patch fixes both these issues.
Firstly, `PendingRnSplice` differentiates between a user-written splice
and an implicit lift. Then, the Lift instance is precisely requested
with a specific origin in the typechecker. If the instance fails to be
solved, the message is reported using the `TcRnBadlyLevelled`
constructor (like a normal level error).
Fixes #26031, #26035
- - - - -
44b8cee2 by Cheng Shao at 2025-06-18T15:34:46-04:00
testsuite: add T26120 marked as broken
- - - - -
894a04f3 by Cheng Shao at 2025-06-18T15:34:46-04:00
compiler: fix GHC.SysTools.Ar archive member size writing logic
This patch fixes a long-standing bug in `GHC.SysTools.Ar` that emits
the wrong archive member size in each archive header. It should encode
the exact length of the member payload, excluding any padding byte,
otherwise malformed archive that extracts a broken object with an
extra trailing byte could be created.
Apart from the in-tree `T26120` test, I've also created an out-of-tree
testsuite at https://github.com/TerrorJack/ghc-ar-quickcheck that
contains QuickCheck roundtrip tests for `GHC.SysTools.Ar`. With this
fix, simple roundtrip tests and `writeGNUAr`/GNU `ar` roundtrip test
passes. There might be more bugs lurking in here, but this patch is
still a critical bugfix already.
Fixes #26120 #22586.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
f677ab5f by Lauren Yim at 2025-06-18T15:35:37-04:00
fix some typos in the warnings page in the user guide
- - - - -
b968e1c1 by Rodrigo Mesquita at 2025-06-18T15:36:18-04:00
Add a frozen callstack to throwGhcException
Fixes #25956
- - - - -
a5e0c3a3 by fendor at 2025-06-18T15:36:59-04:00
Update using.rst to advertise full mhu support for GHCi
- - - - -
d3e60e97 by Ryan Scott at 2025-06-18T22:29:21-04:00
Deprecate -Wdata-kinds-tc, make DataKinds issues in typechecker become errors
!11314 introduced the `-Wdata-kinds-tc` warning as part of a fix for #22141.
This was a temporary stopgap measure to allow users who were accidentally
relying on code which needed the `DataKinds` extension in order to typecheck
without having to explicitly enable the extension.
Now that some amount of time has passed, this patch deprecates
`-Wdata-kinds-tc` and upgrades any `DataKinds`-related issues in the
typechecker (which were previously warnings) into errors.
- - - - -
fd5b5177 by Ryan Hendrickson at 2025-06-18T22:30:06-04:00
haddock: Add redact-type-synonyms pragma
`{-# OPTIONS_HADDOCK redact-type-synonyms #-}` pragma will hide the RHS
of type synonyms, and display the result kind instead, if the RHS
contains any unexported types.
- - - - -
2575b1b7 by Ben Gamari at 2025-06-20T17:54:38-04:00
compiler: Import AnnotationWrapper from ghc-internal
Since `GHC.Desugar` exported from `base` has been deprecated.
- - - - -
9c80671c by Ben Gamari at 2025-06-20T17:54:38-04:00
ghc-compact: Eliminate dependency on ghc-prim
- - - - -
67e3d352 by Ben Gamari at 2025-06-20T17:54:38-04:00
ghc-heap: Eliminate dependency on ghc-prim
- - - - -
0aee0a92 by Ben Gamari at 2025-06-20T17:54:38-04:00
ghc-heap: Drop redundant import
- - - - -
22f4787a by Ben Gamari at 2025-06-20T17:54:38-04:00
ghc-prim: Bump version to 0.13.1
There are no interface changes from 0.13.0 but the implementation now
lives in `ghc-internal`.
- - - - -
b9ba4267 by Ben Gamari at 2025-06-20T17:54:38-04:00
template-haskell: Bump version number to 2.24.0.0
Bumps exceptions submodule.
- - - - -
d0a9a57a by Ben Gamari at 2025-06-20T17:54:46-04:00
Bump GHC version number to 9.14
- - - - -
4ea2e111 by Ben Gamari at 2025-06-20T17:55:08-04:00
Bump parsec to 3.1.18.0
Bumps parsec submodule.
- - - - -
45339d74 by Ben Gamari at 2025-06-20T17:55:15-04:00
unix: Bump to 2.8.7.0
Bumps unix submodule.
- - - - -
62eb3cdd by Ben Gamari at 2025-06-20T17:55:20-04:00
binary: Bump to 0.8.9.3
Bumps binary submodule.
- - - - -
cafec215 by Ben Gamari at 2025-06-20T17:55:25-04:00
Win32: Bump to 2.14.2.0
Bumps Win32 submodule.
- - - - -
175eb5fb by Ben Gamari at 2025-06-20T17:55:29-04:00
base: Bump version to 4.22.0
Bumps various submodules.
- - - - -
186 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Expr.hs-boot
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Stg/EnforceEpt/Types.hs
- compiler/GHC/SysTools/Ar.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Gen/Splice.hs-boot
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/TH.hs
- compiler/GHC/Tc/Utils/Concrete.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/ThLevelIndex.hs
- compiler/GHC/Utils/Panic.hs
- compiler/Language/Haskell/Syntax/Expr.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- configure.ac
- docs/users_guide/9.14.1-notes.rst
- docs/users_guide/using-warnings.rst
- docs/users_guide/using.rst
- libffi-tarballs
- libraries/Win32
- libraries/array
- libraries/base/base.cabal.in
- libraries/binary
- libraries/deepseq
- libraries/directory
- libraries/exceptions
- libraries/filepath
- libraries/ghc-boot-th/ghc-boot-th.cabal.in
- libraries/ghc-boot/ghc-boot.cabal.in
- libraries/ghc-compact/GHC/Compact.hs
- libraries/ghc-compact/GHC/Compact/Serialized.hs
- libraries/ghc-compact/ghc-compact.cabal
- libraries/ghc-experimental/ghc-experimental.cabal.in
- libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc
- libraries/ghc-heap/ghc-heap.cabal.in
- libraries/ghc-prim/changelog.md
- libraries/ghc-prim/ghc-prim.cabal
- libraries/ghci/ghci.cabal.in
- libraries/haskeline
- libraries/hpc
- libraries/os-string
- libraries/parsec
- libraries/process
- libraries/semaphore-compat
- libraries/stm
- libraries/template-haskell/template-haskell.cabal.in
- libraries/terminfo
- libraries/text
- libraries/unix
- rts/include/stg/MachRegs.h
- testsuite/tests/annotations/should_fail/annfail03.stderr
- testsuite/tests/annotations/should_fail/annfail09.stderr
- testsuite/tests/dependent/should_fail/T13135_simple.stderr
- testsuite/tests/diagnostic-codes/codes.stdout
- + testsuite/tests/ghc-api/T26120.hs
- + testsuite/tests/ghc-api/T26120.stdout
- testsuite/tests/ghc-api/all.T
- testsuite/tests/linear/should_fail/LinearTHFail.stderr
- testsuite/tests/linters/notes.stdout
- testsuite/tests/perf/compiler/hard_hole_fits.stderr
- testsuite/tests/quasiquotation/T3953.stderr
- testsuite/tests/quasiquotation/qq001/qq001.stderr
- testsuite/tests/quasiquotation/qq002/qq002.stderr
- testsuite/tests/quasiquotation/qq003/qq003.stderr
- testsuite/tests/quasiquotation/qq004/qq004.stderr
- + testsuite/tests/quotes/LiftErrMsg.hs
- + testsuite/tests/quotes/LiftErrMsg.stderr
- + testsuite/tests/quotes/LiftErrMsgDefer.hs
- + testsuite/tests/quotes/LiftErrMsgDefer.stderr
- + testsuite/tests/quotes/LiftErrMsgTyped.hs
- + testsuite/tests/quotes/LiftErrMsgTyped.stderr
- + testsuite/tests/quotes/QQError.hs
- + testsuite/tests/quotes/QQError.stderr
- testsuite/tests/quotes/T10384.stderr
- testsuite/tests/quotes/TH_localname.stderr
- testsuite/tests/quotes/all.T
- + testsuite/tests/rep-poly/T26107.hs
- testsuite/tests/rep-poly/all.T
- testsuite/tests/splice-imports/SI03.stderr
- testsuite/tests/splice-imports/SI05.stderr
- testsuite/tests/splice-imports/SI16.stderr
- testsuite/tests/splice-imports/SI18.stderr
- testsuite/tests/splice-imports/SI20.stderr
- testsuite/tests/splice-imports/SI25.stderr
- testsuite/tests/splice-imports/SI28.stderr
- testsuite/tests/splice-imports/SI31.stderr
- + testsuite/tests/th/QQInQuote.hs
- + testsuite/tests/th/QQTopError.hs
- + testsuite/tests/th/QQTopError.stderr
- testsuite/tests/th/T10598_TH.stderr
- testsuite/tests/th/T14681.stderr
- testsuite/tests/th/T16976z.stderr
- testsuite/tests/th/T17804.stderr
- testsuite/tests/th/T17820a.stderr
- testsuite/tests/th/T17820b.stderr
- testsuite/tests/th/T17820c.stderr
- testsuite/tests/th/T17820d.stderr
- testsuite/tests/th/T17820e.stderr
- testsuite/tests/th/T23829_hasty.stderr
- testsuite/tests/th/T23829_hasty_b.stderr
- testsuite/tests/th/T5508.stderr
- testsuite/tests/th/T5795.stderr
- testsuite/tests/th/TH_Lift.stderr
- testsuite/tests/th/all.T
- testsuite/tests/th/overloaded/TH_overloaded_constraints_fail.stderr
- + testsuite/tests/typecheck/should_compile/T20873c.hs
- − testsuite/tests/typecheck/should_compile/T22141a.stderr
- − testsuite/tests/typecheck/should_compile/T22141b.stderr
- − testsuite/tests/typecheck/should_compile/T22141c.stderr
- − testsuite/tests/typecheck/should_compile/T22141d.stderr
- − testsuite/tests/typecheck/should_compile/T22141e.stderr
- + testsuite/tests/typecheck/should_compile/T25992.hs
- + testsuite/tests/typecheck/should_compile/T25992.stderr
- testsuite/tests/typecheck/should_compile/all.T
- − testsuite/tests/typecheck/should_fail/T20873c.hs
- − testsuite/tests/typecheck/should_fail/T20873c.stderr
- testsuite/tests/typecheck/should_compile/T22141a.hs → testsuite/tests/typecheck/should_fail/T22141a.hs
- testsuite/tests/typecheck/should_fail/T22141a.stderr
- testsuite/tests/typecheck/should_compile/T22141b.hs → testsuite/tests/typecheck/should_fail/T22141b.hs
- testsuite/tests/typecheck/should_fail/T22141b.stderr
- testsuite/tests/typecheck/should_compile/T22141c.hs → testsuite/tests/typecheck/should_fail/T22141c.hs
- testsuite/tests/typecheck/should_fail/T22141c.stderr
- testsuite/tests/typecheck/should_compile/T22141d.hs → testsuite/tests/typecheck/should_fail/T22141d.hs
- testsuite/tests/typecheck/should_fail/T22141d.stderr
- testsuite/tests/typecheck/should_compile/T22141e.hs → testsuite/tests/typecheck/should_fail/T22141e.hs
- testsuite/tests/typecheck/should_fail/T22141e.stderr
- testsuite/tests/typecheck/should_compile/T22141e_Aux.hs → testsuite/tests/typecheck/should_fail/T22141e_Aux.hs
- testsuite/tests/typecheck/should_fail/all.T
- testsuite/tests/typecheck/should_fail/tcfail097.stderr
- testsuite/tests/vdq-rta/should_fail/T23739_fail_case.hs
- testsuite/tests/vdq-rta/should_fail/T23739_fail_case.stderr
- utils/check-exact/ExactPrint.hs
- utils/haddock/CHANGES.md
- utils/haddock/doc/cheatsheet/haddocks.md
- utils/haddock/doc/markup.rst
- utils/haddock/haddock-api/haddock-api.cabal
- utils/haddock/haddock-api/src/Haddock/Backends/LaTeX.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/GhcUtils.hs
- utils/haddock/haddock-api/src/Haddock/Interface.hs
- utils/haddock/haddock-api/src/Haddock/Interface/AttachInstances.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock-test/haddock-test.cabal
- utils/haddock/haddock.cabal
- + utils/haddock/html-test/ref/RedactTypeSynonyms.html
- + utils/haddock/html-test/src/RedactTypeSynonyms.hs
- + utils/haddock/latex-test/ref/RedactTypeSynonyms/RedactTypeSynonyms.tex
- + utils/haddock/latex-test/src/RedactTypeSynonyms/RedactTypeSynonyms.hs
- utils/hsc2hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de5e7327eb4b9778bbbffcbc2de687…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de5e7327eb4b9778bbbffcbc2de687…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc] Pushed new branch wip/teo/fix-containers-upper-bound
by Teo Camarasu (@teo) 20 Jun '25
by Teo Camarasu (@teo) 20 Jun '25
20 Jun '25
Teo Camarasu pushed new branch wip/teo/fix-containers-upper-bound at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/teo/fix-containers-upper-bound
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/T25282] 2 commits: Expose ghc-internal unit id through the settings file
by Teo Camarasu (@teo) 20 Jun '25
by Teo Camarasu (@teo) 20 Jun '25
20 Jun '25
Teo Camarasu pushed to branch wip/T25282 at Glasgow Haskell Compiler / GHC
Commits:
6d791567 by Teo Camarasu at 2025-06-20T17:43:18+01:00
Expose ghc-internal unit id through the settings file
This in combination with the unit id of the compiler library allows
cabal to know of the two unit ids that should not be reinstalled (in
specific circumstances) as:
- when using plugins, we want to link against exactly the compiler unit
id
- when using TemplateHaskell we want to link against exactly the package
that contains the TemplateHaskell interfaces, which is `ghc-internal`
See: <https://github.com/haskell/cabal/issues/10087>
Resolves #25282
- - - - -
ae14bd72 by Teo Camarasu at 2025-06-20T17:43:35+01:00
linters: lint-whitespace: bump upper-bound for containers
- - - - -
4 changed files:
- compiler/GHC/Driver/Session.hs
- compiler/Setup.hs
- hadrian/src/Rules/Generate.hs
- linters/lint-whitespace/lint-whitespace.cabal
Changes:
=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -3460,6 +3460,7 @@ compilerInfo dflags
("Project Patch Level1", cProjectPatchLevel1),
("Project Patch Level2", cProjectPatchLevel2),
("Project Unit Id", cProjectUnitId),
+ ("ghc-internal Unit Id", cGhcInternalUnitId), -- See Note [Special unit-ids]
("Booter version", cBooterVersion),
("Stage", cStage),
("Build platform", cBuildPlatformString),
@@ -3513,6 +3514,23 @@ compilerInfo dflags
expandDirectories :: FilePath -> Maybe FilePath -> String -> String
expandDirectories topd mtoold = expandToolDir useInplaceMinGW mtoold . expandTopDir topd
+-- Note [Special unit-ids]
+-- ~~~~~~~~~~~~~~~~~~~~~~~
+-- Certain units are special to the compiler:
+-- - Wired-in identifiers reference a specific unit-id of `ghc-internal`.
+-- - GHC plugins must be linked against a specific unit-id of `ghc`,
+-- namely the same one as the compiler.
+-- - When using Template Haskell, splices refer to the Template Haskell
+-- interface defined in `ghc-internal`, and must be linked against the same
+-- unit-id as the compiler.
+--
+-- We therefore expose the unit-id of `ghc-internal` ("ghc-internal Unit Id") and
+-- ghc ("Project Unit Id") through `ghc --info`.
+--
+-- This allows build tools to act accordingly, eg, if a user wishes to build a
+-- GHC plugin, `cabal-install` might force them to use the exact `ghc` unit
+-- that the compiler was linked against.
+
{- -----------------------------------------------------------------------------
Note [DynFlags consistency]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=====================================
compiler/Setup.hs
=====================================
@@ -11,6 +11,7 @@ import Distribution.Verbosity
import Distribution.Simple.Program
import Distribution.Simple.Utils
import Distribution.Simple.Setup
+import Distribution.Simple.PackageIndex
import System.IO
import System.Process
@@ -22,6 +23,7 @@ import qualified Data.Map as Map
import GHC.ResponseFile
import System.Environment
+
main :: IO ()
main = defaultMainWithHooks ghcHooks
where
@@ -56,7 +58,7 @@ primopIncls =
]
ghcAutogen :: Verbosity -> LocalBuildInfo -> IO ()
-ghcAutogen verbosity lbi@LocalBuildInfo{pkgDescrFile,withPrograms,componentNameMap}
+ghcAutogen verbosity lbi@LocalBuildInfo{pkgDescrFile,withPrograms,componentNameMap,installedPkgs}
= do
-- Get compiler/ root directory from the cabal file
let Just compilerRoot = takeDirectory <$> pkgDescrFile
@@ -96,9 +98,14 @@ ghcAutogen verbosity lbi@LocalBuildInfo{pkgDescrFile,withPrograms,componentNameM
Just [LibComponentLocalBuildInfo{componentUnitId}] -> unUnitId componentUnitId
_ -> error "Couldn't find unique cabal library when building ghc"
+ let cGhcInternalUnitId = case lookupPackageName installedPkgs (mkPackageName "ghc-internal") of
+ -- We assume there is exactly one copy of `ghc-internal` in our dependency closure
+ [(_,[packageInfo])] -> unUnitId $ installedUnitId packageInfo
+ _ -> error "Couldn't find unique ghc-internal library when building ghc"
+
-- Write GHC.Settings.Config
configHsPath = autogenPackageModulesDir lbi </> "GHC/Settings/Config.hs"
- configHs = generateConfigHs cProjectUnitId settings
+ configHs = generateConfigHs cProjectUnitId cGhcInternalUnitId settings
createDirectoryIfMissingVerbose verbosity True (takeDirectory configHsPath)
rewriteFileEx verbosity configHsPath configHs
@@ -110,8 +117,9 @@ getSetting settings kh kr = go settings kr
Just v -> Right v
generateConfigHs :: String -- ^ ghc's cabal-generated unit-id, which matches its package-id/key
+ -> String -- ^ ghc-internal's cabal-generated unit-id, which matches its package-id/key
-> [(String,String)] -> String
-generateConfigHs cProjectUnitId settings = either error id $ do
+generateConfigHs cProjectUnitId cGhcInternalUnitId settings = either error id $ do
let getSetting' = getSetting $ (("cStage","2"):) settings
buildPlatform <- getSetting' "cBuildPlatformString" "Host platform"
hostPlatform <- getSetting' "cHostPlatformString" "Target platform"
@@ -127,6 +135,7 @@ generateConfigHs cProjectUnitId settings = either error id $ do
, " , cBooterVersion"
, " , cStage"
, " , cProjectUnitId"
+ , " , cGhcInternalUnitId"
, " ) where"
, ""
, "import GHC.Prelude.Basic"
@@ -150,4 +159,7 @@ generateConfigHs cProjectUnitId settings = either error id $ do
, ""
, "cProjectUnitId :: String"
, "cProjectUnitId = " ++ show cProjectUnitId
+ , ""
+ , "cGhcInternalUnitId :: String"
+ , "cGhcInternalUnitId = " ++ show cGhcInternalUnitId
]
=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -601,6 +601,8 @@ generateConfigHs = do
-- 'pkgUnitId' on 'compiler' (the ghc-library package) to create the
-- unit-id in both situations.
cProjectUnitId <- expr . (`pkgUnitId` compiler) =<< getStage
+
+ cGhcInternalUnitId <- expr . (`pkgUnitId` ghcInternal) =<< getStage
return $ unlines
[ "module GHC.Settings.Config"
, " ( module GHC.Version"
@@ -610,6 +612,7 @@ generateConfigHs = do
, " , cBooterVersion"
, " , cStage"
, " , cProjectUnitId"
+ , " , cGhcInternalUnitId"
, " ) where"
, ""
, "import GHC.Prelude.Basic"
@@ -633,6 +636,9 @@ generateConfigHs = do
, ""
, "cProjectUnitId :: String"
, "cProjectUnitId = " ++ show cProjectUnitId
+ , ""
+ , "cGhcInternalUnitId :: String"
+ , "cGhcInternalUnitId = " ++ show cGhcInternalUnitId
]
where
stageString (Stage0 InTreeLibs) = "1"
=====================================
linters/lint-whitespace/lint-whitespace.cabal
=====================================
@@ -24,7 +24,7 @@ executable lint-whitespace
process
^>= 1.6,
containers
- >= 0.6 && <0.8,
+ >= 0.6 && <0.9,
base
>= 4.14 && < 5,
text
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44c4682da95e578d0024f1728517f5…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44c4682da95e578d0024f1728517f5…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/T26115] 2 commits: Discard outer casts
by Simon Peyton Jones (@simonpj) 20 Jun '25
by Simon Peyton Jones (@simonpj) 20 Jun '25
20 Jun '25
Simon Peyton Jones pushed to branch wip/T26115 at Glasgow Haskell Compiler / GHC
Commits:
649ab08b by Simon Peyton Jones at 2025-06-20T15:28:28+01:00
Discard outer casts
- - - - -
f0dc94fc by Simon Peyton Jones at 2025-06-20T17:36:07+01:00
Nearly there
- - - - -
8 changed files:
- compiler/GHC/Core.hs
- compiler/GHC/HsToCore/Binds.hs
- + testsuite/tests/simplCore/should_compile/T26115.hs
- + testsuite/tests/simplCore/should_compile/T26115.stderr
- + testsuite/tests/simplCore/should_compile/T26116.hs
- + testsuite/tests/simplCore/should_compile/T26116.stderr
- + testsuite/tests/simplCore/should_compile/T26117.hs
- testsuite/tests/simplCore/should_compile/all.T
Changes:
=====================================
compiler/GHC/Core.hs
=====================================
@@ -39,7 +39,7 @@ module GHC.Core (
isId, cmpAltCon, cmpAlt, ltAlt,
-- ** Simple 'Expr' access functions and predicates
- bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts,
+ bindersOf, bindersOfBinds, rhssOfBind, rhssOfBinds, rhssOfAlts,
foldBindersOfBindStrict, foldBindersOfBindsStrict,
collectBinders, collectTyBinders, collectTyAndValBinders,
collectNBinders, collectNValBinders_maybe,
@@ -2154,6 +2154,11 @@ rhssOfBind :: Bind b -> [Expr b]
rhssOfBind (NonRec _ rhs) = [rhs]
rhssOfBind (Rec pairs) = [rhs | (_,rhs) <- pairs]
+rhssOfBinds :: [Bind b] -> [Expr b]
+rhssOfBinds [] = []
+rhssOfBinds (NonRec _ rhs : bs) = rhs : rhssOfBinds bs
+rhssOfBinds (Rec pairs : bs) = map snd pairs ++ rhssOfBinds bs
+
rhssOfAlts :: [Alt b] -> [Expr b]
rhssOfAlts alts = [e | Alt _ _ e <- alts]
=====================================
compiler/GHC/HsToCore/Binds.hs
=====================================
@@ -66,11 +66,11 @@ import GHC.Builtin.Types ( naturalTy, typeSymbolKind, charTy )
import GHC.Tc.Types.Evidence
import GHC.Types.Id
-import GHC.Types.Id.Info (IdDetails(..))
+import GHC.Types.Id.Info
import GHC.Types.Name
import GHC.Types.Var.Set
import GHC.Types.Var.Env
-import GHC.Types.Var( EvVar )
+import GHC.Types.Var( EvVar, mkLocalVar )
import GHC.Types.SrcLoc
import GHC.Types.Basic
import GHC.Types.Unique.Set( nonDetEltsUniqSet )
@@ -1141,7 +1141,7 @@ dsSpec poly_rhs (SpecPrag poly_id spec_co spec_inl)
dsSpec poly_rhs (SpecPragE { spe_fn_nm = poly_nm
, spe_fn_id = poly_id
- , spe_inl = inl
+ , spe_inl = spec_inl
, spe_bndrs = bndrs
, spe_call = the_call })
-- SpecPragE case: See Note [Handling new-form SPECIALISE pragmas] in GHC.Tc.Gen.Sig
@@ -1149,68 +1149,134 @@ dsSpec poly_rhs (SpecPragE { spe_fn_nm = poly_nm
unsetWOptM Opt_WarnIdentities $
zapUnspecables $
dsLExpr the_call
- ; dsSpec_help poly_nm poly_id poly_rhs inl bndrs ds_call }
+ ; dsSpec_help poly_nm poly_id poly_rhs spec_inl bndrs ds_call }
dsSpec_help :: Name -> Id -> CoreExpr -- Function to specialise
-> InlinePragma -> [Var] -> CoreExpr
-> DsM (Maybe (OrdList (Id,CoreExpr), CoreRule))
-dsSpec_help poly_nm poly_id poly_rhs inl orig_bndrs ds_call
- = do {
- -- Simplify the (desugared) call; see wrinkle (SP1)
- -- in Note [Desugaring new-form SPECIALISE pragmas]
- ; dflags <- getDynFlags
- ; let simpl_opts = initSimpleOpts dflags
- core_call = simpleOptExprNoInline simpl_opts ds_call
-
- ; case decomposeCall poly_id core_call of {
- Nothing -> do { diagnosticDs (DsRuleLhsTooComplicated ds_call core_call)
- ; return Nothing } ;
-
+dsSpec_help poly_nm poly_id poly_rhs spec_inl orig_bndrs ds_call
+ = do { mb_call_info <- decomposeCall poly_id ds_call
+ ; case mb_call_info of {
+ Nothing -> return Nothing ;
Just (binds, rule_lhs_args) ->
- do { let locals = mkVarSet orig_bndrs `extendVarSetList` bindersOfBinds binds
+ do { dflags <- getDynFlags
+ ; this_mod <- getModule
+ ; uniq <- newUnique
+ ; let locals = mkVarSet orig_bndrs `extendVarSetList` bindersOfBinds binds
is_local :: Var -> Bool
is_local v = v `elemVarSet` locals
rule_bndrs = scopedSort (exprsSomeFreeVarsList is_local rule_lhs_args)
- rn_binds = getRenamings orig_bndrs binds rule_bndrs
+ rn_binds = getRenamings orig_bndrs binds rule_bndrs
- spec_binds = pickSpecBinds is_local (mkVarSet rule_bndrs)
- (rn_binds ++ binds)
+ spec_binds = pickSpecBinds is_local (mkVarSet rule_bndrs) binds
+ -- Make spec_bndrs, the variables to pass to the specialised
+ -- function, by filtering out the rule_bndrs that aren't needed
spec_binds_bndr_set = mkVarSet (bindersOfBinds spec_binds)
+ `minusVarSet` exprsFreeVars (rhssOfBinds rn_binds)
spec_bndrs = filterOut (`elemVarSet` spec_binds_bndr_set) rule_bndrs
- mk_spec_body fn_body = mkLets spec_binds $
+ mk_spec_body fn_body = mkLets (rn_binds ++ spec_binds) $
mkApps fn_body rule_lhs_args
-- ToDo: not mkCoreApps! That uses exprType on fun which
-- fails in specUnfolding, sigh
+ poly_name = idName poly_id
+ spec_occ = mkSpecOcc (getOccName poly_name)
+ spec_name = mkInternalName uniq spec_occ (getSrcSpan poly_name)
+ id_inl = idInlinePragma poly_id
+
+ simpl_opts = initSimpleOpts dflags
+ fn_unf = realIdUnfolding poly_id
+ spec_unf = specUnfolding simpl_opts spec_bndrs mk_spec_body rule_lhs_args fn_unf
+ spec_info = vanillaIdInfo
+ `setInlinePragInfo` specFunInlinePrag poly_id id_inl spec_inl
+ `setUnfoldingInfo` spec_unf
+ spec_id = mkLocalVar (idDetails poly_id) spec_name ManyTy spec_ty spec_info
+ -- Specialised binding is toplevel, hence Many.
+
+ -- The RULE looks like
+ -- RULE "USPEC" forall rule_bndrs. f rule_lhs_args = $sf spec_bndrs
+ -- The specialised function looks like
+ -- $sf spec_bndrs = mk_spec_body <f's original rhs>
+ -- We also use mk_spec_body to specialise the methods in f's stable unfolding
+ -- NB: spec_bindrs is a subset of rule_bndrs
+ rule = mkSpecRule dflags this_mod False rule_act (text "USPEC")
+ poly_id rule_bndrs rule_lhs_args
+ (mkVarApps (Var spec_id) spec_bndrs)
+
+ rule_ty = exprType (mkApps (Var poly_id) rule_lhs_args)
+ spec_ty = mkLamTypes spec_bndrs rule_ty
+ spec_rhs = mkLams spec_bndrs (mk_spec_body poly_rhs)
+
+ result = (unitOL (spec_id, spec_rhs), rule)
+ -- NB: do *not* use makeCorePair on (spec_id,spec_rhs), because
+ -- makeCorePair overwrites the unfolding, which we have
+ -- just created using specUnfolding
; tracePm "dsSpec(new route)" $
vcat [ text "poly_id" <+> ppr poly_id
, text "unfolding" <+> ppr (realIdUnfolding poly_id)
, text "orig_bndrs" <+> pprCoreBinders orig_bndrs
+ , text "locals" <+> ppr locals
+ , text "fvs" <+> ppr (exprsSomeFreeVarsList is_local rule_lhs_args)
, text "ds_call" <+> ppr ds_call
- , text "core_call" <+> ppr core_call
, text "binds" <+> ppr binds
- , text "rule_bndrs" <+> ppr rule_bndrs
, text "rule_lhs_args" <+> ppr rule_lhs_args
+ , text "rule_bndrs" <+> ppr rule_bndrs
, text "spec_bndrs" <+> ppr spec_bndrs
, text "rn_binds" <+> ppr rn_binds
, text "spec_binds" <+> ppr spec_binds ]
- ; finishSpecPrag poly_nm poly_rhs
- rule_bndrs poly_id rule_lhs_args
- spec_bndrs mk_spec_body inl } } }
+ ; dsWarnOrphanRule rule
+
+ ; case checkUselessSpecPrag poly_id rule_lhs_args spec_bndrs
+ no_act_spec spec_inl rule_act of
+ Nothing -> return (Just result)
+
+ Just reason -> do { diagnosticDs $ DsUselessSpecialisePragma poly_nm is_dfun reason
+ ; if uselessSpecialisePragmaKeepAnyway reason
+ then return (Just result)
+ else return Nothing } } } }
+
+ where
+ -- See Note [Activation pragmas for SPECIALISE]
+ -- no_act_spec is True if the user didn't write an explicit
+ -- phase specification in the SPECIALISE pragma
+ id_inl = idInlinePragma poly_id
+ inl_prag_act = inlinePragmaActivation id_inl
+ spec_prag_act = inlinePragmaActivation spec_inl
+ no_act_spec = case inlinePragmaSpec spec_inl of
+ NoInline _ -> isNeverActive spec_prag_act
+ Opaque _ -> isNeverActive spec_prag_act
+ _ -> isAlwaysActive spec_prag_act
+ rule_act | no_act_spec = inl_prag_act -- Inherit
+ | otherwise = spec_prag_act -- Specified by user
+
+ is_dfun = case idDetails poly_id of
+ DFunId {} -> True
+ _ -> False
decomposeCall :: Id -> CoreExpr
- -> Maybe ( [CoreBind]
- , [CoreExpr] ) -- Args of the call
-decomposeCall poly_id binds
- = go [] binds
+ -> DsM (Maybe ([CoreBind], [CoreExpr] ))
+-- Decompose the call into (let <binds> in f <args>)
+decomposeCall poly_id ds_call
+ = do { -- Simplify the (desugared) call; see wrinkle (SP1)
+ -- in Note [Desugaring new-form SPECIALISE pragmas]
+ ; dflags <- getDynFlags
+ ; let simpl_opts = initSimpleOpts dflags
+ core_call = simpleOptExprNoInline simpl_opts ds_call
+
+ ; case go [] core_call of {
+ Nothing -> do { diagnosticDs (DsRuleLhsTooComplicated ds_call core_call)
+ ; return Nothing } ;
+ Just result -> return (Just result) } }
where
- go acc (Let bind body)
- = go (bind:acc) body
+ go :: [CoreBind] -> CoreExpr -> Maybe ([CoreBind],[CoreExpr])
+ go acc (Let bind body) = go (bind:acc) body
+ go acc (Cast e _) = go acc e -- Discard outer casts
+ -- ToDo: document this
go acc e
| (Var fun, args) <- collectArgs e
= assertPpr (fun == poly_id) (ppr fun $$ ppr poly_id) $
@@ -1218,6 +1284,40 @@ decomposeCall poly_id binds
| otherwise
= Nothing
+ -- Is this SPECIALISE pragma useless?
+checkUselessSpecPrag :: Id -> [CoreExpr]
+ -> [Var] -> Bool -> InlinePragma -> Activation
+ -> Maybe UselessSpecialisePragmaReason
+checkUselessSpecPrag poly_id rule_lhs_args
+ spec_bndrs no_act_spec spec_inl rule_act
+ | isJust (isClassOpId_maybe poly_id)
+ -- There is no point in trying to specialise a class op
+ -- Moreover, classops don't (currently) have an inl_sat arity set
+ -- (it would be Just 0) and that in turn makes makeCorePair bleat
+ = Just UselessSpecialiseForClassMethodSelector
+
+ | no_act_spec, isNeverActive rule_act
+ -- Function is NOINLINE, and the specialisation inherits that
+ -- See Note [Activation pragmas for SPECIALISE]
+ = Just UselessSpecialiseForNoInlineFunction
+
+ | all is_nop_arg rule_lhs_args, not (isInlinePragma spec_inl)
+ -- The specialisation does nothing.
+ -- But don't complain if it is SPECIALISE INLINE (#4444)
+ = Just UselessSpecialiseNoSpecialisation
+
+ | otherwise
+ = Nothing
+
+ where
+ is_nop_arg (Type {}) = True
+ is_nop_arg (Coercion {}) = True
+ is_nop_arg (Cast e _) = is_nop_arg e
+ is_nop_arg (Tick _ e) = is_nop_arg e
+ is_nop_arg (Var x) = x `elem` spec_bndrs
+ is_nop_arg _ = False
+
+
getRenamings :: [Var] -> [CoreBind] -- orig_bndrs and bindings
-> [Var] -- rule_bndrs
-> [CoreBind] -- Binds some of the orig_bndrs to a rule_bndr
@@ -1238,8 +1338,8 @@ getRenamings orig_bndrs binds rule_bndrs
go (bind : binds)
| NonRec b rhs <- bind
, Just (v, mco) <- getCastedVar rhs
- , Just e <- lookupVarEnv renamings v
- = extendVarEnv renamings b (mkCastMCo e (mkSymMCo mco))
+ , Just e <- lookupVarEnv renamings b
+ = extendVarEnv renamings v (mkCastMCo e (mkSymMCo mco))
| otherwise
= renamings
where
@@ -1256,201 +1356,12 @@ pickSpecBinds is_local known_bndrs (bind:binds)
where
keep_me rhs = isEmptyVarSet (exprSomeFreeVars bad_var rhs)
bad_var v = is_local v && not (v `elemVarSet` known_bndrs)
-{-
-grabSpecBinds :: (Var -> Bool) -> VarSet -> [CoreBind]
- -> ([CoreBind], [CoreBind])
-grabSpecBinds is_local rule_bndrs rev_binds
- = (reverse rename_binds, spec_binds)
- where
- (known_bndrs, (rename_binds, other_binds))
- = get_renamings rule_bndrs ([],[]) rev_binds
- spec_binds = pick_spec_binds known_bndrs other_binds
-
- ------------------------
- get_renamings :: VarSet -- Variables bound by a successful match on the call
- -> ([CoreBind],[CoreBind]) -- Accumulating parameter, in order
- -> [CoreBind] -- Reversed, innermost first
- -> ( VarSet
- , ([CoreBind] -- Renamings, in order
- , [CoreBind])) -- Other bindings, in order
- get_renamings bndrs acc [] = (bndrs, acc)
-
- get_renamings bndrs (rn_binds, other_binds) (bind : binds)
- | NonRec d r <- bind
- , d `elemVarSet` bndrs
- , Just (v, mco) <- getCastedVar r
- , is_local v
- , let flipped_bind = NonRec v (mkCastMCo (Var d) (mkSymMCo mco))
- = get_renamings (bndrs `extendVarSet` v)
- (flipped_bind:rn_binds, other_binds)
- binds
- | otherwise
- = get_renamings bndrs
- (rn_binds, bind:other_binds)
- binds
-
- ------------------------
- pick_spec_binds :: VarSet -> [CoreBind] -> [CoreBind]
- pick_spec_binds _ [] = []
- pick_spec_binds known_bndrs (bind:binds)
- | all keep_me (rhssOfBind bind)
- , let known_bndrs' = known_bndrs `extendVarSetList` bindersOf bind
- = bind : pick_spec_binds known_bndrs' binds
- | otherwise
- = pick_spec_binds known_bndrs binds
- where
- keep_me rhs = isEmptyVarSet (exprSomeFreeVars bad_var rhs)
- bad_var v = is_local v && not (v `elemVarSet` known_bndrs)
--}
getCastedVar :: CoreExpr -> Maybe (Var, MCoercionR)
getCastedVar (Var v) = Just (v, MRefl)
getCastedVar (Cast (Var v) co) = Just (v, MCo co)
getCastedVar _ = Nothing
-{-
- where
- go :: VarSet -- Quantified variables, or dependencies thereof
- -> [CoreBind] -- Reversed list of constant evidence bindings
- -> CoreExpr
- -> Maybe (IdSet, [CoreBind], [CoreExpr])
- go qevs acc (Cast e _)
- = go qevs acc e
- go qevs acc (Let bind e)
- | not (all (isPredTy . varType) bndrs)
- -- A normal 'let' is too complicated
- -- But we definitely include quantified constraints
- -- E.g. this is fine: let (d :: forall a. Eq a => Eq (f a) = d2)
- = Nothing
-
- -- (a) (1) in Note [prepareSpecLHS]
- | all (transfer_to_spec_rhs qevs) $
- rhssOfBind bind -- One of the `const_binds`
- = go qevs (bind:acc) e
-
- -- (a) (2) in Note [prepareSpecLHS]
- | otherwise
- = go (qevs `extendVarSetList` bndrs) acc e
- where
- bndrs = bindersOf bind
-
- go qevs acc e
- | (Var fun, args) <- collectArgs e
- -- (a) (3) in Note [prepareSpecLHS]
- = assertPpr (fun == poly_id) (ppr fun $$ ppr poly_id) $
- Just (qevs, reverse acc, args)
- | otherwise
- = Nothing
-
- transfer_to_spec_rhs qevs rhs
- where
- is_quant_id v = isId v && v `elemVarSet` qevs
- -- See (a) (2) in Note [prepareSpecLHS]
--}
-
-finishSpecPrag :: Name -> CoreExpr -- RHS to specialise
- -> [Var] -> Id -> [CoreExpr] -- RULE LHS pattern
- -> [Var] -> (CoreExpr -> CoreExpr) -> InlinePragma -- Specialised form
- -> DsM (Maybe (OrdList (Id,CoreExpr), CoreRule))
-finishSpecPrag poly_nm poly_rhs rule_bndrs poly_id rule_lhs_args
- spec_bndrs mk_spec_body spec_inl
- | Just reason <- mb_useless
- = do { diagnosticDs $ DsUselessSpecialisePragma poly_nm is_dfun reason
- ; if uselessSpecialisePragmaKeepAnyway reason
- then Just <$> finish_prag
- else return Nothing }
-
- | otherwise
- = Just <$> finish_prag
-
- where
- -- The RULE looks like
- -- RULE "USPEC" forall rule_bndrs. f rule_lhs_args = $sf spec_bndrs
- -- The specialised function looks like
- -- $sf spec_bndrs = mk_spec_body <f's original rhs>
- -- We also use mk_spec_body to specialise the methods in f's stable unfolding
- -- NB: spec_bindrs is a subset of rule_bndrs
- finish_prag
- = do { this_mod <- getModule
- ; uniq <- newUnique
- ; dflags <- getDynFlags
- ; let poly_name = idName poly_id
- spec_occ = mkSpecOcc (getOccName poly_name)
- spec_name = mkInternalName uniq spec_occ (getSrcSpan poly_name)
-
- simpl_opts = initSimpleOpts dflags
- fn_unf = realIdUnfolding poly_id
- spec_unf = specUnfolding simpl_opts spec_bndrs mk_spec_body rule_lhs_args fn_unf
- spec_id = mkLocalId spec_name ManyTy spec_ty
- -- Specialised binding is toplevel, hence Many.
- `setInlinePragma` specFunInlinePrag poly_id id_inl spec_inl
- `setIdUnfolding` spec_unf
-
- rule = mkSpecRule dflags this_mod False rule_act (text "USPEC")
- poly_id rule_bndrs rule_lhs_args
- (mkVarApps (Var spec_id) spec_bndrs)
-
- rule_ty = exprType (mkApps (Var poly_id) rule_lhs_args)
- spec_ty = mkLamTypes spec_bndrs rule_ty
- spec_rhs = mkLams spec_bndrs (mk_spec_body poly_rhs)
-
- ; dsWarnOrphanRule rule
-
- ; tracePm "dsSpec" (vcat
- [ text "fun:" <+> ppr poly_id
- , text "spec_bndrs:" <+> ppr spec_bndrs
- , text "rule_lhs_args:" <+> ppr rule_lhs_args ])
- ; return (unitOL (spec_id, spec_rhs), rule) }
- -- NB: do *not* use makeCorePair on (spec_id,spec_rhs), because
- -- makeCorePair overwrites the unfolding, which we have
- -- just created using specUnfolding
-
- -- Is this SPECIALISE pragma useless?
- mb_useless :: Maybe UselessSpecialisePragmaReason
- mb_useless
- | isJust (isClassOpId_maybe poly_id)
- -- There is no point in trying to specialise a class op
- -- Moreover, classops don't (currently) have an inl_sat arity set
- -- (it would be Just 0) and that in turn makes makeCorePair bleat
- = Just UselessSpecialiseForClassMethodSelector
-
- | no_act_spec, isNeverActive rule_act
- -- Function is NOINLINE, and the specialisation inherits that
- -- See Note [Activation pragmas for SPECIALISE]
- = Just UselessSpecialiseForNoInlineFunction
-
- | all is_nop_arg rule_lhs_args, not (isInlinePragma spec_inl)
- -- The specialisation does nothing.
- -- But don't complain if it is SPECIALISE INLINE (#4444)
- = Just UselessSpecialiseNoSpecialisation
-
- | otherwise
- = Nothing
-
- -- See Note [Activation pragmas for SPECIALISE]
- -- no_act_spec is True if the user didn't write an explicit
- -- phase specification in the SPECIALISE pragma
- id_inl = idInlinePragma poly_id
- inl_prag_act = inlinePragmaActivation id_inl
- spec_prag_act = inlinePragmaActivation spec_inl
- no_act_spec = case inlinePragmaSpec spec_inl of
- NoInline _ -> isNeverActive spec_prag_act
- Opaque _ -> isNeverActive spec_prag_act
- _ -> isAlwaysActive spec_prag_act
- rule_act | no_act_spec = inl_prag_act -- Inherit
- | otherwise = spec_prag_act -- Specified by user
-
- is_nop_arg (Type {}) = True
- is_nop_arg (Coercion {}) = True
- is_nop_arg (Cast e _) = is_nop_arg e
- is_nop_arg (Tick _ e) = is_nop_arg e
- is_nop_arg (Var x) = x `elem` spec_bndrs
- is_nop_arg _ = False
-
- is_dfun = case idDetails poly_id of
- DFunId {} -> True
- _ -> False
-
specFunInlinePrag :: Id -> InlinePragma
-> InlinePragma -> InlinePragma
-- See Note [Activation pragmas for SPECIALISE]
=====================================
testsuite/tests/simplCore/should_compile/T26115.hs
=====================================
@@ -0,0 +1,10 @@
+module T26115 where
+
+class C a b where { op1, op2 :: a -> b -> Bool
+ ; op2 = op1 }
+
+instance C Bool b where { op1 _ _ = True }
+
+instance C p q => C [p] q where
+ op1 [x] y = op1 x y
+ {-# SPECIALISE instance C [Bool] b #-}
=====================================
testsuite/tests/simplCore/should_compile/T26115.stderr
=====================================
@@ -0,0 +1,6 @@
+[GblId[DFunId],
+ Unf=DFun: \ (@b_awW) ->
+[GblId[DFunId],
+ Unf=DFun: \ (@b_aBU) ->
+[GblId[DFunId],
+ Unf=DFun: \ (@p_awR) (@q_awS) (v_B1 :: C p_awR q_awS) ->
=====================================
testsuite/tests/simplCore/should_compile/T26116.hs
=====================================
@@ -0,0 +1,18 @@
+{-# LANGUAGE QuantifiedConstraints #-}
+{-# OPTIONS_GHC -fno-warn-missing-methods #-}
+
+module T26116 where
+
+data T a = MkT a
+
+instance Eq (T a) where
+ x == y = True
+
+class (forall b. Eq (T b)) => D a where { dop :: a -> a }
+
+class C f a where { op1,op2 :: f a -> Int }
+
+instance (Eq (f a), D a) => C f a where
+ op1 x | x==x = 3
+ | otherwise = 4
+ {-# SPECIALISE instance D a => C T a #-}
=====================================
testsuite/tests/simplCore/should_compile/T26116.stderr
=====================================
@@ -0,0 +1,12 @@
+
+==================== Tidy Core rules ====================
+"USPEC $cop1 @T @_"
+ forall (@a) ($dD :: D a) ($dEq :: Eq (T a)).
+ $fCTYPEfa_$cop1 @T @a $dEq $dD
+ = \ _ [Occ=Dead] -> I# 3#
+"USPEC $fCTYPEfa @T @_"
+ forall (@a) ($dD :: D a) ($dEq :: Eq (T a)).
+ $fCTYPEfa @T @a $dEq $dD
+ = $fCTYPEfa_$s$fCTYPEfa @a $dD
+
+
=====================================
testsuite/tests/simplCore/should_compile/T26117.hs
=====================================
@@ -0,0 +1,15 @@
+{-# LANGUAGE UndecidableInstances, TypeFamilies #-}
+
+module T26117 where
+
+type family F a
+type instance F Int = Bool
+
+class Eq (F a) => D a b where { dop1, dop2 :: a -> b -> b }
+
+class C a b where { op1,op2 :: F a -> a -> b -> Int }
+
+instance (Eq (F a), D a b) => C a [b] where
+ op1 x _ _ | x==x = 3
+ | otherwise = 4
+ {-# SPECIALISE instance D Int b => C Int [b] #-}
=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -548,3 +548,6 @@ test('T25965', normal, compile, ['-O'])
test('T25703', [grep_errmsg(r'SPEC')], compile, ['-O -fpolymorphic-specialisation -ddump-rule-firings'])
test('T25703a', [grep_errmsg(r'SPEC')], compile, ['-O -fpolymorphic-specialisation -ddump-rule-firings'])
+test('T26115', [grep_errmsg(r'DFun')], compile, ['-O -ddump-simpl'])
+test('T26116', normal, compile, ['-O -ddump-rules'])
+
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d765a87164bdffd2a6494108b3fbcf…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d765a87164bdffd2a6494108b3fbcf…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/T25282] bump lint-whitespace containers upper-bound
by Teo Camarasu (@teo) 20 Jun '25
by Teo Camarasu (@teo) 20 Jun '25
20 Jun '25
Teo Camarasu pushed to branch wip/T25282 at Glasgow Haskell Compiler / GHC
Commits:
44c4682d by Teo Camarasu at 2025-06-20T16:29:25+01:00
bump lint-whitespace containers upper-bound
- - - - -
1 changed file:
- linters/lint-whitespace/lint-whitespace.cabal
Changes:
=====================================
linters/lint-whitespace/lint-whitespace.cabal
=====================================
@@ -24,7 +24,7 @@ executable lint-whitespace
process
^>= 1.6,
containers
- >= 0.6 && <0.8,
+ >= 0.6 && <0.9,
base
>= 4.14 && < 5,
text
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44c4682da95e578d0024f1728517f53…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44c4682da95e578d0024f1728517f53…
You're receiving this email because of your account on gitlab.haskell.org.
1
0