Alan Zimmerman pushed to branch wip/az/epa-tidy-locatedxxx-27 at Glasgow Haskell Compiler / GHC

Commits:

22 changed files:

Changes:

  • .gitlab/ci.sh
    ... ... @@ -982,23 +982,24 @@ function lint_changelog() {
    982 982
         exit 0
    
    983 983
       fi
    
    984 984
     
    
    985
    -  # Check that the MR adds at least one changelog entry.
    
    985
    +  # Check that the MR adds or modifies at least one changelog entry.
    
    986 986
       git fetch --depth=1 \
    
    987 987
         "$CI_MERGE_REQUEST_PROJECT_URL" \
    
    988 988
         "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
    
    989 989
     
    
    990
    -  local added
    
    991
    -  added=$(git diff --name-only --diff-filter=A \
    
    990
    +  local entries
    
    991
    +  entries=$(git diff --name-only --diff-filter=AM \
    
    992 992
         "$CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA" -- \
    
    993 993
         'changelog.d/' | grep -v '^changelog.d/config$' || true)
    
    994 994
     
    
    995
    -  if [ -z "$added" ]; then
    
    995
    +  if [ -z "$entries" ]; then
    
    996 996
         error "No changelog entry found in changelog.d/"
    
    997
    -    echo "Please add a changelog entry file describing your user-facing changes."
    
    997
    +    echo "Please add a changelog entry file describing your user-facing changes,"
    
    998
    +    echo "or add this MR to the 'mrs' field of an existing entry."
    
    998 999
         echo "If this MR does not need a changelog entry, apply the 'no-changelog' label."
    
    999 1000
         exit 1
    
    1000 1001
       fi
    
    1001
    -  echo "Found changelog entries: $added"
    
    1002
    +  echo "Found changelog entries: $entries"
    
    1002 1003
     
    
    1003 1004
       # Build changelog-d with the bootstrap compiler and validate all entries
    
    1004 1005
       # (checks required fields, section names, and the MR number).
    

  • changelog.d/27641
    1
    +section: ghci
    
    2
    +synopsis: Don't accept modules in `:add` that the loader will reject
    
    3
    +issues: #27641
    
    4
    +mrs: !16734

  • changelog.d/T27455
    ... ... @@ -4,5 +4,5 @@ mrs: !16274
    4 4
     synopsis:
    
    5 5
       Don't drop `ExceptionContext` in `SomeException(toException)`
    
    6 6
     description:
    
    7
    -  Previously the implementation of ``Exception(toException)`` given to `SomeException` would inappropriately drop the carried `ExceptionContext`. Now ``toException = id``, faithfully implementing the semantics proposed in :ref:`CLC Proposal #200 <https://github.com/haskell/core-libraries-committee/issues/200>`.
    
    7
    +  Previously the implementation of ``Exception(toException)`` given to `SomeException` would inappropriately drop the carried `ExceptionContext`. Now ``toException = id``, faithfully implementing the semantics proposed in `CLC Proposal #200 <https://github.com/haskell/core-libraries-committee/issues/200>`_.
    
    8 8
     

  • changelog.d/semaphore-v2
    ... ... @@ -12,7 +12,7 @@ description:
    12 12
       semaphores); its reported protocol version remains v1.
    
    13 13
     
    
    14 14
       When GHC receives a ``-jsem`` name whose protocol version it does not
    
    15
    -  support, it now emits a ``-Wsemaphore-version-mismatch`` warning and
    
    15
    +  support, it now emits a :ghc-flag:`-Wsemaphore-open-failure` warning and
    
    16 16
       falls back to ``-j1`` rather than crashing. ``ghc --info`` exposes the
    
    17 17
       supported version in a new ``"Semaphore version"`` entry so
    
    18 18
       cabal-install can detect a mismatch before invoking GHC.
    

  • changelog.d/unit-index
    1 1
     section: compiler
    
    2 2
     synopsis: Use global ``UnitIndex`` to deduplicate ``UnitInfo``s over multiple home units
    
    3
    -issues: #27500 #26423 #27748
    
    4
    -mrs: !16115 !16598
    
    3
    +issues: #27500 #26423 #27748 #27834
    
    4
    +mrs: !16115 !16598 !16743
    
    5 5
     
    
    6 6
     description: {
    
    7 7
         The ``UnitState`` used to be duplicated for all ``HomeUnitEnv``, not sharing any of the ``UnitInfo``s.
    

  • compiler/GHC/Parser.y
    ... ... @@ -1796,10 +1796,10 @@ cvars1 :: { [RecordPatSynField GhcPs] }
    1796 1796
     where_decls :: { LocatedA (OrdList (LHsDecl GhcPs), EpToken "where", AnnList) }
    
    1797 1797
             : 'where' '{' decls '}'       {% amsA' (sLL $1 $> (thdOf3 $ unLoc $3,
    
    1798 1798
                                                     epTok $1,
    
    1799
    -                                                AnnList (AnnListLayout (fstOf3 $ unLoc $3)) (ListBraces (epTok $2) (epTok $4)) (sndOf3 $ unLoc $3))) }
    
    1799
    +                                                AnnList AnnListBraces (ListBraces (epTok $2) (epTok $4)) (sndOf3 $ unLoc $3))) }
    
    1800 1800
             | 'where' vocurly decls close {% amsA' (sLL $1 $3 (thdOf3 $ unLoc $3,
    
    1801 1801
                                                     epTok $1,
    
    1802
    -                                                AnnList (AnnListLayout (fstOf3 $ unLoc $3)) ListNone (sndOf3 $ unLoc $3))) }
    
    1802
    +                                                AnnList (AnnListLayout (glR $3)) ListNone (sndOf3 $ unLoc $3))) }
    
    1803 1803
     
    
    1804 1804
     pattern_synonym_sig :: { LSig GhcPs }
    
    1805 1805
             : 'pattern' con_list '::' sigtype
    
    ... ... @@ -1935,7 +1935,7 @@ decls :: { Located (EpaLocation, [EpToken ";"], OrdList (LHsDecl GhcPs)) }
    1935 1935
             | {- empty -}                   { noLoc (noAnn, [],nilOL) }
    
    1936 1936
     
    
    1937 1937
     decllist :: { Located (AnnList,Located (OrdList (LHsDecl GhcPs))) }
    
    1938
    -        : '{'            decls '}'     { sLL $1 $> (AnnList (AnnListLayout (fstOf3 $ unLoc $2)) (ListBraces (epTok $1) (epTok $3)) (sndOf3 $ unLoc $2)
    
    1938
    +        : '{'            decls '}'     { sLL $1 $> (AnnList AnnListBraces (ListBraces (epTok $1) (epTok $3)) (sndOf3 $ unLoc $2)
    
    1939 1939
                                                        ,sL1 $2 $ thdOf3 $ unLoc $2) }
    
    1940 1940
             |     vocurly    decls close   { sL1 $2    (AnnList (AnnListLayout (fstOf3 $ unLoc $2)) ListNone (sndOf3 $ unLoc $2)
    
    1941 1941
                                                        ,sL1 $2 $ thdOf3 $ unLoc $2) }
    
    ... ... @@ -1951,7 +1951,7 @@ binds :: { Located (HsLocalBinds GhcPs) }
    1951 1951
                                       ; return (sL1 $1 $ HsValBinds (EpAnn (glR $1) (AnnList la p s) cs, noEpTok) val_binds)} }
    
    1952 1952
     
    
    1953 1953
             | '{'            dbinds '}'     {% acs (comb3 $1 $2 $3) (\loc cs -> (L loc
    
    1954
    -                                             $ HsIPBinds (EpAnn (spanAsAnchor (comb3 $1 $2 $3)) (AnnList (AnnListLayout$ glR $2) (ListBraces (epTok $1) (epTok $3)) []) cs, noEpTok) (IPBinds noExtField (reverse $ unLoc $2)))) }
    
    1954
    +                                             $ HsIPBinds (EpAnn (spanAsAnchor (comb3 $1 $2 $3)) (AnnList AnnListBraces (ListBraces (epTok $1) (epTok $3)) []) cs, noEpTok) (IPBinds noExtField (reverse $ unLoc $2)))) }
    
    1955 1955
     
    
    1956 1956
             |     vocurly    dbinds close   {% acs (gl $2) (\loc cs -> (L loc
    
    1957 1957
                                                  $ HsIPBinds (EpAnn (glR $1) (AnnList (AnnListLayout $ glR $2) ListNone []) cs, noEpTok) (IPBinds noExtField (reverse $ unLoc $2)))) }
    
    ... ... @@ -3542,12 +3542,12 @@ guardquals1 :: { Located [LStmt GhcPs (LHsExpr GhcPs)] }
    3542 3542
     altslist(PATS) :: { forall b. DisambECP b => PV (LocatedA ([LMatch GhcPs (LocatedA b)], AnnList)) }
    
    3543 3543
             : '{'        alts(PATS) '}'    { $2 >>= \ $2 -> amsA'
    
    3544 3544
                                                (sLL $1 $> (reverse (snd $ unLoc $2),
    
    3545
    -                                           (AnnList (AnnListLayout $ glR $2) (ListBraces (epTok $1) (epTok $3)) (fst $ unLoc $2)))) }
    
    3545
    +                                           (AnnList AnnListBraces (ListBraces (epTok $1) (epTok $3)) (fst $ unLoc $2)))) }
    
    3546 3546
             | vocurly    alts(PATS)  close { $2 >>= \ $2 -> amsA'
    
    3547 3547
                                                (L (getLoc $2) (reverse (snd $ unLoc $2),
    
    3548 3548
                                                (AnnList (AnnListLayout $ glR $2) ListNone (fst $ unLoc $2)))) }
    
    3549
    -        | '{'              '}'   { amsA' (sLL $1 $> ([], (AnnList AnnListNoLayout (ListBraces (epTok $1) (epTok $2)) []))) }
    
    3550
    -        | vocurly          close { return $ noLocA ([], noAnn) }
    
    3549
    +        | '{'              '}'   { amsA' (sLL $1 $> ([], (AnnList AnnListBraces (ListBraces (epTok $1) (epTok $2)) []))) }
    
    3550
    +        | vocurly          close { return $ noLocA ([], AnnList (AnnListLayout $ glR $1) ListNone []) }
    
    3551 3551
     
    
    3552 3552
     alts(PATS) :: { forall b. DisambECP b => PV (Located ([EpToken ";"],[LMatch GhcPs (LocatedA b)])) }
    
    3553 3553
             : alts1(PATS)              { $1 >>= \ $1 -> return $
    
    ... ... @@ -3656,7 +3656,7 @@ apat : aexp {% (checkPattern <=< runPV) (unECP $1) }
    3656 3656
     
    
    3657 3657
     stmtlist :: { forall b. DisambECP b => PV (LocatedA (AnnList, Located [LocatedA (Stmt GhcPs (LocatedA b))])) }
    
    3658 3658
             : '{'           stmts '}'       { $2 >>= \ $2 ->
    
    3659
    -                                          amsA' (sLL $1 $> (AnnList (AnnListLayout (spanAsAnchor $ stmtsLoc $2)) (ListBraces (epTok $1) (epTok $3)) (fromOL $ fst $ unLoc $2)
    
    3659
    +                                          amsA' (sLL $1 $> (AnnList AnnListBraces (ListBraces (epTok $1) (epTok $3)) (fromOL $ fst $ unLoc $2)
    
    3660 3660
                                                                , sL1 $2 $ reverse $ snd $ unLoc $2))}
    
    3661 3661
             |     vocurly   stmts close     { $2 >>= \ $2 ->
    
    3662 3662
                                               amsA' (L (stmtsLoc $2) (AnnList (AnnListLayout (spanAsAnchor $ stmtsLoc $2)) ListNone (fromOL $ fst $ unLoc $2)
    

  • compiler/GHC/Unit/External/Wired.hs
    ... ... @@ -5,6 +5,7 @@ module GHC.Unit.External.Wired (
    5 5
       isWireMapEmpty,
    
    6 6
       lookupWireMap,
    
    7 7
       listWireMap,
    
    8
    +  nonDetFoldWireMap,
    
    8 9
       -- * 'UnwireMap'
    
    9 10
       UnwireMap,
    
    10 11
       emptyUnwireMap,
    
    ... ... @@ -48,6 +49,9 @@ lookupWireMap uid (WireMap wmap) = lookupUniqMap wmap uid
    48 49
     listWireMap :: WireMap -> [(UnitId, UnitId)]
    
    49 50
     listWireMap (WireMap wmap) = nonDetUniqMapToList wmap
    
    50 51
     
    
    52
    +nonDetFoldWireMap :: ((UnitId, UnitId) -> b -> b) -> b -> WireMap -> b
    
    53
    +nonDetFoldWireMap go z (WireMap uniq) = nonDetFoldUniqMap go z uniq
    
    54
    +
    
    51 55
     -- | The reverse of 'WireMap'.
    
    52 56
     -- Records the mapping from the wired-in 'UnitId' to the on-disk 'UnitId'.
    
    53 57
     newtype UnwireMap =
    

  • compiler/GHC/Unit/State.hs
    ... ... @@ -286,6 +286,21 @@ trustUnits elements (TrustOverlay to) = TrustOverlay $ foldl' (\ acc uid -> addT
    286 286
     emptyTrustOverlay :: TrustOverlay
    
    287 287
     emptyTrustOverlay = TrustOverlay emptyUniqMap
    
    288 288
     
    
    289
    +-- | For all values in the 'WireMap', copy the recorded trust/distrust
    
    290
    +-- for the wired-in unit id.
    
    291
    +--
    
    292
    +extendForWireMap :: TrustOverlay -> WireMap -> TrustOverlay
    
    293
    +extendForWireMap to wmap =
    
    294
    +  nonDetFoldWireMap go to wmap
    
    295
    +  where
    
    296
    +    go (onDiskUid, wiredInUid) overlay =
    
    297
    +      case lookupTrustOverlay overlay onDiskUid of
    
    298
    +        Nothing -> overlay
    
    299
    +        Just Trusted ->
    
    300
    +          trustUnits [wiredInUid] overlay
    
    301
    +        Just Distrusted ->
    
    302
    +          distrustUnits [wiredInUid] overlay
    
    303
    +
    
    289 304
     {-
    
    290 305
     Note [Sharing 'UnitInfo's across the 'UnitEnv']
    
    291 306
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ... ... @@ -957,7 +972,7 @@ mkUnitState logger unit_index cfg = do
    957 972
              , explicitUnits                = explicit_pkgs
    
    958 973
              , homeUnitDepends              = home_unit_deps
    
    959 974
              , unitInfoMap                  = pkg_db
    
    960
    -         , trustedUnits                 = trustUnitsOverlay
    
    975
    +         , trustedUnits                 = trustUnitsOverlay `extendForWireMap` wired_map
    
    961 976
              , moduleNameProvidersMap       = mod_map
    
    962 977
              , pluginModuleNameProvidersMap = mkModuleNameProvidersMap logger (unitConfigAllowVirtual cfg) pkg_db plugin_vis_map
    
    963 978
              , packageNameMap               = pkgname_map
    

  • ghc/GHCi/UI.hs
    ... ... @@ -180,6 +180,7 @@ import GHC.IO.Handle ( hFlushAll )
    180 180
     import GHC.TopHandler ( topHandler )
    
    181 181
     
    
    182 182
     import qualified GHC.Unit.Module.Graph as GHC
    
    183
    +import GHC.Unit.Home.Graph (memberHugUnit)
    
    183 184
     
    
    184 185
     -----------------------------------------------------------------------------
    
    185 186
     
    
    ... ... @@ -2400,7 +2401,9 @@ addModule files = do
    2400 2401
           result <- liftIO $
    
    2401 2402
             Finder.findImportedModule hsc_env Finder.LookupUser m NoPkgQual
    
    2402 2403
           case result of
    
    2403
    -        Found _ _ -> return True
    
    2404
    +        -- We could find a module from a dependency, such as `Data.List`, but we can't
    
    2405
    +        -- actualy load that unless the module is located in a home unit.
    
    2406
    +        Found _ m | moduleUnit m `memberHugUnit` hsc_HUG hsc_env -> return True
    
    2404 2407
             _ -> do reportError (GhciModuleError $ GhciModuleNotFound (moduleNameString m))
    
    2405 2408
                     return False
    
    2406 2409
     
    

  • libraries/base/changelog.md
    ... ... @@ -7,6 +7,7 @@
    7 7
       * Add `Data.List.NonEmpty.{zip{3..7},zipWith{3..7},unzip{3..7}}` ([CLC proposal #409)(https://github.com/haskell/core-libraries-committee/issues/409))
    
    8 8
       * Ensure that `Data.List.elem` and `notElem` can be specialized even when no list fusion happens. ([CLC proposal #412)(https://github.com/haskell/core-libraries-committee/issues/412))
    
    9 9
       * Introduce `Data.Double` and `Data.Float` modules. ([CLC proposal #378](https://github.com/haskell/core-libraries-committee/issues/378))
    
    10
    +  * Remove `bitSize` from `MINIMAL` pragma of `class Bits`. ([CLC proposal #440](https://github.com/haskell/core-libraries-committee/issues/440))
    
    10 11
       * Change `Generically a`'s `Monoid` definition to require a `Semigroup` constraint, and define its `mconcat` using `(<>)` from that constraint. ([CLC proposal #413](https://github.com/haskell/core-libraries-committee/issues/413))
    
    11 12
       * Add `withEmptyCallStack` to `GHC.Stack`. ([CLC proposal #428](https://github.com/haskell/core-libraries-committee/issues/428))
    
    12 13
       * Add new `Data.RealFloat` module re-exporting `RealFloat` from `GHC.Float` ([CLC proposal #394](https://github.com/haskell/core-libraries-committee/issues/394))
    

  • libraries/ghc-internal/src/GHC/Internal/Bits.hs
    ... ... @@ -90,7 +90,7 @@ class Eq a => Bits a where
    90 90
         {-# MINIMAL (.&.), (.|.), xor, complement,
    
    91 91
                     (shift | (shiftL, shiftR)),
    
    92 92
                     (rotate | (rotateL, rotateR)),
    
    93
    -                bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount #-}
    
    93
    +                bitSizeMaybe, isSigned, testBit, bit, popCount #-}
    
    94 94
     
    
    95 95
         -- | Bitwise \"and\"
    
    96 96
         (.&.) :: a -> a -> a
    

  • testsuite/tests/ghci/scripts/T27641.script
    1
    +:add Data.List
    
    2
    +:reload
    
    3
    +putStrLn ":add Data.List should fail and a subsequent :reload should succeed"

  • testsuite/tests/ghci/scripts/T27641.stderr
    1
    +<interactive>: error: [GHCi-23305] Module Data.List not found
    
    2
    +

  • testsuite/tests/ghci/scripts/T27641.stdout
    1
    +:add Data.List should fail and a subsequent :reload should succeed

  • testsuite/tests/ghci/scripts/T27834.hs
    1
    +{-# LANGUAGE Haskell2010 #-}
    
    2
    +{-# LANGUAGE Safe #-}
    
    3
    +module Main where
    
    4
    +
    
    5
    +-- Importing a wired-in in module should honour trustworthiness
    
    6
    +import GHC.Internal.Char (chr)
    
    7
    +
    
    8
    +main :: IO ()
    
    9
    +main = print (chr 120)

  • testsuite/tests/ghci/scripts/T27834.script
    1
    +:load T27834
    
    2
    +putStrLn "Can import trusted module from ghc-internal"

  • testsuite/tests/ghci/scripts/T27834.stdout
    1
    +Can import trusted module from ghc-internal

  • testsuite/tests/ghci/scripts/all.T
    ... ... @@ -402,3 +402,5 @@ test('GhciPackageRename',
    402 402
          ghci_script,
    
    403 403
          ['GhciPackageRename.script'])
    
    404 404
     test('T26233', normal, ghci_script, ['T26233.script'])
    
    405
    +test('T27641', normal, ghci_script, ['T27641.script'])
    
    406
    +test('T27834', [extra_hc_opts("-fpackage-trust -trust base -trust ghc-internal -package ghc-internal")], ghci_script, ['T27834.script'])

  • testsuite/tests/interface-stability/base-exports.stdout
    No preview for this file type
  • testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
    No preview for this file type
  • testsuite/tests/interface-stability/base-exports.stdout-mingw32
    No preview for this file type
  • testsuite/tests/parser/should_compile/DumpSemis.stderr
    ... ... @@ -364,8 +364,7 @@
    364 364
                            ((,)
    
    365 365
                             (Right
    
    366 366
                              (AnnList
    
    367
    -                          (AnnListLayout
    
    368
    -                           (EpaSpan { DumpSemis.hs:11:8-13 }))
    
    367
    +                          (AnnListBraces)
    
    369 368
                               (ListBraces
    
    370 369
                                (EpTok (EpaSpan { DumpSemis.hs:11:6 }))
    
    371 370
                                (EpTok (EpaSpan { DumpSemis.hs:11:15 })))
    
    ... ... @@ -627,8 +626,7 @@
    627 626
                      ((,)
    
    628 627
                       (Right
    
    629 628
                        (AnnList
    
    630
    -                    (AnnListLayout
    
    631
    -                     (EpaSpan { DumpSemis.hs:(16,5)-(18,5) }))
    
    629
    +                    (AnnListBraces)
    
    632 630
                         (ListBraces
    
    633 631
                          (EpTok (EpaSpan { DumpSemis.hs:16:3 }))
    
    634 632
                          (EpTok (EpaSpan { DumpSemis.hs:19:3 })))
    
    ... ... @@ -880,8 +878,7 @@
    880 878
                      ((,)
    
    881 879
                       (Right
    
    882 880
                        (AnnList
    
    883
    -                    (AnnListLayout
    
    884
    -                     (EpaSpan { DumpSemis.hs:22:12-28 }))
    
    881
    +                    (AnnListBraces)
    
    885 882
                         (ListBraces
    
    886 883
                          (EpTok (EpaSpan { DumpSemis.hs:22:10 }))
    
    887 884
                          (EpTok (EpaSpan { DumpSemis.hs:22:30 })))
    
    ... ... @@ -1936,8 +1933,7 @@
    1936 1933
                        (EpAnn
    
    1937 1934
                         (EpaSpan { DumpSemis.hs:34:13-31 })
    
    1938 1935
                         (AnnList
    
    1939
    -                     (AnnListLayout
    
    1940
    -                      (EpaSpan { DumpSemis.hs:34:18-30 }))
    
    1936
    +                     (AnnListBraces)
    
    1941 1937
                          (ListBraces
    
    1942 1938
                           (EpTok (EpaSpan { DumpSemis.hs:34:13 }))
    
    1943 1939
                           (EpTok (EpaSpan { DumpSemis.hs:34:31 })))
    
    ... ... @@ -2333,8 +2329,7 @@
    2333 2329
                       ((,)
    
    2334 2330
                        (FromSource)
    
    2335 2331
                        (AnnList
    
    2336
    -                    (AnnListLayout
    
    2337
    -                     (EpaSpan { DumpSemis.hs:(38,6)-(43,13) }))
    
    2332
    +                    (AnnListBraces)
    
    2338 2333
                         (ListBraces
    
    2339 2334
                          (EpTok (EpaSpan { DumpSemis.hs:38:4 }))
    
    2340 2335
                          (EpTok (EpaSpan { DumpSemis.hs:44:4 })))