[Git][ghc/ghc][ghc-9.10] 8 commits: Bump parsec submodule to 3.1.17.0
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Thu Apr 11 12:27:33 UTC 2024
Ben Gamari pushed to branch ghc-9.10 at Glasgow Haskell Compiler / GHC
Commits:
76a0e7f6 by Ben Gamari at 2024-03-29T17:02:25-04:00
Bump parsec submodule to 3.1.17.0
- - - - -
5a85e5b1 by Ben Gamari at 2024-04-04T14:24:55-04:00
Bump Cabal submodule to current state of 3.12 branch
- - - - -
0fb5c97d by Ben Gamari at 2024-04-08T13:36:25-04:00
base: Deprecate GHC.Pack
See #21461.
- - - - -
834fe22d by Apoorv Ingle at 2024-04-09T21:17:38-04:00
Fix for #24552 (see testcase T24552)
Fixes for a bug in desugaring pattern synonyms matches, introduced
while working on on expanding `do`-blocks in #18324
The `matchWrapper` unecessarily (and incorrectly) filtered out the
default wild patterns in a match. Now the wild pattern alternative is
simply ignored by the pm check as its origin is `Generated`.
The current code now matches the expected semantics according to the language spec.
(cherry picked from commit 0c48f2b952ad4ee995e4eafa458b7a8d3c442415)
- - - - -
76a0f8f2 by Ben Gamari at 2024-04-11T00:07:21-04:00
Bump process submodule to 1.6.19.0
Addresses Windows command-line injection vulnerability.
- - - - -
086698ba by Ben Gamari at 2024-04-11T00:07:21-04:00
Bump unix submodule to 2.8.5.1
Closes #24640.
- - - - -
21c9c1bc by Ben Gamari at 2024-04-11T00:07:21-04:00
ghcup-metadata: Use Debian 9 binaries on Ubuntu 16, 17
Closes #24646.
- - - - -
aa5b34e1 by Ben Gamari at 2024-04-11T00:07:21-04:00
Bump stm submodule
Fixing #24643
- - - - -
14 changed files:
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/Tc/Gen/Do.hs
- libraries/Cabal
- libraries/base/changelog.md
- libraries/base/src/GHC/Pack.hs
- libraries/parsec
- libraries/process
- libraries/stm
- libraries/unix
- + testsuite/tests/patsyn/should_run/T24552.hs
- + testsuite/tests/patsyn/should_run/T24552.stdout
- testsuite/tests/patsyn/should_run/all.T
- testsuite/tests/process/process004.stdout
Changes:
=====================================
.gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
=====================================
@@ -216,7 +216,8 @@ def mk_new_yaml(release_mode, version, date, pipeline_type, job_map):
, ">= 11": deb11
, "unknown_versioning": deb11 }
, "Linux_Ubuntu" : { "unknown_versioning": ubuntu2004
- , "( >= 16 && < 19 )": ubuntu1804
+ , "( >= 16 && < 18 )": deb9
+ , "( >= 18 && < 19 )": ubuntu1804
}
, "Linux_Mint" : { "< 20": ubuntu1804
, ">= 20": ubuntu2004 }
=====================================
compiler/GHC/HsToCore/Match.hs
=====================================
@@ -29,7 +29,7 @@ import Language.Haskell.Syntax.Basic (Boxity(..))
import {-#SOURCE#-} GHC.HsToCore.Expr (dsExpr)
-import GHC.Types.Basic ( Origin(..), requiresPMC, isDoExpansionGenerated )
+import GHC.Types.Basic ( Origin(..), requiresPMC )
import GHC.Types.SourceText
( FractionalLit,
@@ -765,20 +765,11 @@ one pattern, and match simply only accepts one pattern.
JJQC 30-Nov-1997
-}
-matchWrapper ctxt scrs (MG { mg_alts = L _ matches'
+matchWrapper ctxt scrs (MG { mg_alts = L _ matches
, mg_ext = MatchGroupTc arg_tys rhs_ty origin
})
= do { dflags <- getDynFlags
; locn <- getSrcSpanDs
- ; let matches
- = if any (is_pat_syn_match origin) matches'
- then filter (non_gen_wc origin) matches'
- -- filter out the wild pattern fail alternatives
- -- which have a do expansion origin
- -- They generate spurious overlapping warnings
- -- Due to pattern synonyms treated as refutable patterns
- -- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do
- else matches'
; new_vars <- case matches of
[] -> newSysLocalsDs arg_tys
(m:_) ->
@@ -797,6 +788,8 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches'
, text "matchPmChecked" <+> ppr (isMatchContextPmChecked dflags origin ctxt)])
; matches_nablas <-
if isMatchContextPmChecked dflags origin ctxt
+ -- See Note [Expanding HsDo with XXExprGhcRn] Part 1. Wrinkle 1 for
+ -- pmc for pattern synonyms
-- See Note [Long-distance information] in GHC.HsToCore.Pmc
then addHsScrutTmCs (concat scrs) new_vars $
@@ -843,16 +836,6 @@ matchWrapper ctxt scrs (MG { mg_alts = L _ matches'
$ NEL.nonEmpty
$ replicate (length (grhssGRHSs m)) ldi_nablas
- is_pat_syn_match :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool
- is_pat_syn_match origin (L _ (Match _ _ [L _ (VisPat _ l_pat)] _)) | isDoExpansionGenerated origin
- = isPatSyn l_pat
- is_pat_syn_match _ _ = False
- -- generated match pattern that is not a wildcard
- non_gen_wc :: Origin -> LMatch GhcTc (LHsExpr GhcTc) -> Bool
- non_gen_wc origin (L _ (Match _ _ ([L _ (VisPat _ (L _ (WildPat _)))]) _))
- = not . isDoExpansionGenerated $ origin
- non_gen_wc _ _ = True
-
{- Note [Long-distance information in matchWrapper]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The pattern match checking in matchWrapper is done conditionally, depending
=====================================
compiler/GHC/Tc/Gen/Do.hs
=====================================
@@ -212,7 +212,7 @@ mk_failable_expr doFlav pat@(L loc _) expr fail_op =
mk_fail_block :: HsDoFlavour -> LPat GhcRn -> LHsExpr GhcRn -> FailOperator GhcRn -> TcM (HsExpr GhcRn)
mk_fail_block doFlav pat@(L ploc _) e (Just (SyntaxExprRn fail_op)) =
do dflags <- getDynFlags
- return $ HsLam noAnn LamSingle $ mkMatchGroup (doExpansionOrigin doFlav) -- \
+ return $ HsLam noAnn LamCases $ mkMatchGroup (doExpansionOrigin doFlav) -- \
(wrapGenSpan [ genHsCaseAltDoExp doFlav (mkVisPat pat) e -- pat -> expr
, fail_alt_case dflags pat fail_op -- _ -> fail "fail pattern"
])
@@ -356,25 +356,42 @@ The `fail`-block wrapping is done by `GHC.Tc.Gen.Do.mk_failable_expr`.
of do-notation is that if the pattern match fails, we fail in the monad, *not* just crash
at runtime.
-* That call of `fail` will (rightly) automatically generate a `MonadFail` constraint. So if the
- pattern is irrefuable, we don't want to generate that `fail` alternative, else we'll generate
- a `MonadFail` constraint that isn't needed.
+* According to the language specification, when the pattern is irrefutable,
+ we should not add the `fail` alternative. This is important because
+ the occurrence of `fail` means that the typechecker will generate a `MonadFail` constraint,
+ and irrefutable patterns shouldn't need a fail alternative.
-* _Wrinkle 1_: For pattern synonyms, we always wrap it with a `fail`-block.
- When the pattern is irrefutable, we do not add the fail block.
- This is important because the occurrence of `fail` means that the typechecker
- will generate a `MonadFail` constraint, and the language spec says that
- we should not do that for irrefutable patterns.
+* _Wrinkel 1_: Note that pattern synonyms count as refutable during type checking,
+ (see `GHC.Tc.Gen.Pat.isIrrefutableHsPatRnTcM`). They will hence generate a
+ `MonadFail` constraint and they will always be wrapped in a `fail`able-block.
- Note that pattern synonyms count as refutable (see `isIrrefutableHsPat`), and hence will generate
- a `MonadFail` constraint, also, we would get a pattern match checker's redundant pattern warnings.
- because after desugaring, it is marked as irrefutable! To avoid such
- spurious warnings and type checker errors, we filter out those patterns that appear
- in a do expansion generated match in `HsToCore.Match.matchWrapper`. (see testcase Typeable1.hs)
+ Consider a patten synonym declaration (testcase T24552):
+
+ pattern MyJust :: a -> Maybe a
+ pattern MyJust x <- Just x where MyJust = Just
+
+ and a `do`-block with the following bind and return statement
+
+ do { MyJust x <- [MyNothing, MyJust ()]
+ ; return x }
+
+ The `do`-expansion will generate the expansion
+
+ (>>=) ([MyNothing, MyJust ()])
+ (\case MyJust x -> return x -- (1)
+ _ -> fail "failable pattern .. " -- (2)
+ )
+
+ This code (specifically the `match` spanning lines (1) and (2)) is a compiler generated code;
+ the associated `Origin` in tagged `Generated`
+ The alternative statements will thus be ignored by the pattern match check (c.f. `isMatchContextPmChecked`).
+ This ensures we do not generate spurious redundant-pattern-match warnings due to the line (2) above.
+ See Note [Generated code and pattern-match checking]
+ See Note [Long-distance information in matchWrapper]
* _Wrinkle 2_: The call to `fail` will give rise to a `MonadFail` constraint. What `CtOrigin` do we
- attach to that constraint? It should be a good one, because it'll show up in error
- messages when the `MonadFail` constraint can't be solved. Ideally, it should identify the
+ attach to that constraint? When the `MonadFail` constraint can't be solved, it'll show up in error
+ messages and it needs to be a good location. Ideally, it should identify the
pattern `p`. Hence, we wrap the `fail` alternative expression with a `ExpandedPat`
that tags the fail expression with the failable pattern. (See testcase MonadFailErrors.hs)
=====================================
libraries/Cabal
=====================================
@@ -1 +1 @@
-Subproject commit fb3f4d47d261f7401e4ea717ffab31af5d5470fb
+Subproject commit 7d140c56d277c49fb8452729de3bb62c937017a0
=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,7 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
## 4.20.0.0 *TBA*
+ * Deprecate `GHC.Pack` ([#21461](https://gitlab.haskell.org/ghc/ghc/-/issues/21461))
* Export `foldl'` from `Prelude` ([CLC proposal #167](https://github.com/haskell/core-libraries-committee/issues/167))
* The top-level handler for uncaught exceptions now displays the output of `displayException` rather than `show` ([CLC proposal #198](https://github.com/haskell/core-libraries-committee/issues/198))
* Add `permutations` and `permutations1` to `Data.List.NonEmpty` ([CLC proposal #68](https://github.com/haskell/core-libraries-committee/issues/68))
=====================================
libraries/base/src/GHC/Pack.hs
=====================================
@@ -25,6 +25,7 @@
--
module GHC.Pack
+ {-# DEPRECATED "The exports of this module should be instead imported from GHC.Exts" #-}
(packCString#,
unpackCString,
unpackCString#,
=====================================
libraries/parsec
=====================================
@@ -1 +1 @@
-Subproject commit 4a44a8cdaa8c3eaa97a73a6da05940dd3bf7c93b
+Subproject commit 0736c51d0b39a9852cd39259af4cfaf6cafe36a3
=====================================
libraries/process
=====================================
@@ -1 +1 @@
-Subproject commit a53f925e3ee246e2429418b7a088ecaa0976007b
+Subproject commit dfbe62c7d9fc84d2550fc7e7db993dc0aa143ef5
=====================================
libraries/stm
=====================================
@@ -1 +1 @@
-Subproject commit 4e7aa7885b3f9724b19e68d12cbd2774b11b9bd0
+Subproject commit b77afda28b60f526ebb4be436240afd6ca956673
=====================================
libraries/unix
=====================================
@@ -1 +1 @@
-Subproject commit 930a8289f96c5353d120af4fd155446c574709f2
+Subproject commit 69552a5267c7dc5c46a8bceec5ec4b40d26b9463
=====================================
testsuite/tests/patsyn/should_run/T24552.hs
=====================================
@@ -0,0 +1,14 @@
+{-# language PatternSynonyms #-}
+
+module Main where
+
+import Prelude
+import qualified Prelude as P
+
+pattern MyNothing :: Maybe a
+pattern MyNothing <- Nothing where MyNothing = Nothing
+
+pattern MyJust :: a -> Maybe a
+pattern MyJust x <- Just x where MyJust = Just
+
+main = print $ do MyJust x <- [MyNothing, MyJust ()] ; return x
=====================================
testsuite/tests/patsyn/should_run/T24552.stdout
=====================================
@@ -0,0 +1 @@
+[()]
=====================================
testsuite/tests/patsyn/should_run/all.T
=====================================
@@ -17,3 +17,4 @@ test('T11224', normal, compile_and_run, ['-Wincomplete-patterns -Woverlapping-pa
test('T13688', req_th, multimod_compile_and_run, ['T13688', '-v0'])
test('T14228', normal, compile_and_run, [''])
test('records-poly-update', normal, compile_and_run, [''])
+test('T24552', normal, compile_and_run, [''])
\ No newline at end of file
=====================================
testsuite/tests/process/process004.stdout
=====================================
@@ -1,2 +1,2 @@
-Exc: true: runInteractiveProcess: chdir: invalid argument (Bad file descriptor)
+Exc: true: runInteractiveProcess: chdir: does not exist (No such file or directory)
Exc: true: runProcess: chdir: does not exist (No such file or directory)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16e1fca214c4f90d9d881e44cb82bd193231204b...aa5b34e1643df9c44eaebea38cb58dafaf60cb4b
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16e1fca214c4f90d9d881e44cb82bd193231204b...aa5b34e1643df9c44eaebea38cb58dafaf60cb4b
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240411/19cfd086/attachment-0001.html>
More information about the ghc-commits
mailing list