[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Document defaulting of RuntimeReps

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Nov 16 12:28:02 UTC 2023



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00
Document defaulting of RuntimeReps

Fixes #24099

- - - - -
2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00
Second fix to #24083

My earlier fix turns out to be too aggressive for data/type families

See wrinkle (DTV1) in Note [Disconnected type variables]

- - - - -
5d03c316 by Sylvain Henry at 2023-11-16T07:27:36-05:00
Fix unusable units and module reexport interaction (#21097)

This commit fixes an issue with ModUnusable introduced in df0f148feae.

In mkUnusableModuleNameProvidersMap we traverse the list of unusable
units and generate ModUnusable origin for all the modules they contain:
exposed modules, hidden modules, and also re-exported modules. To do
this we have a two-level map:

  ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin

So for each module name "M" in broken unit "u" we have:
  "M" -> u:M -> ModUnusable reason

However in the case of module reexports we were using the *target*
module as a key. E.g. if "u:M" is a reexport for "X" from unit "o":
   "M" -> o:X -> ModUnusable reason

Case 1: suppose a reexport without module renaming (u:M -> o:M) from
unusable unit u:
   "M" -> o:M -> ModUnusable reason

Here it's claiming that the import of M is unusable because a reexport
from u is unusable. But if unit o isn't unusable we could also have in
the map:
   "M" -> o:M -> ModOrigin ...

Issue: the Semigroup instance of ModuleOrigin doesn't handle the case
(ModUnusable <> ModOrigin)

Case 2: similarly we could have 2 unusable units reexporting the same module
without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v
unusable. It gives:

  "M" -> o:M -> ModUnusable ... (for u)
  "M" -> o:M -> ModUnusable ... (for v)

Issue: the Semigroup instance of ModuleOrigin doesn't handle the case
(ModUnusable <> ModUnusable).

This led to #21097, #16996, #11050.

To fix this, in this commit we make ModUnusable track whether the module
used as key is a reexport or not (for better error messages) and we use
the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u
is unusable, we now record:

    "M" -> u:M -> ModUnusable reason reexported=True

So now, we have two cases for a reexport u:M -> o:X:
   - u unusable: "M" -> u:M -> ModUnusable ... reexported=True
   - u usable:   "M" -> o:X -> ModOrigin   ... reexportedFrom=u:M

The second case is indexed with o:X because in this case the Semigroup
instance of ModOrigin is used to combine valid expositions of a module
(directly or via reexports).

Note that module lookup functions select usable modules first (those who
have a ModOrigin value), so it doesn't matter if we add new ModUnusable
entries in the map like this:

  "M" -> {
    u:M -> ModUnusable ... reexported=True
    o:M -> ModOrigin ...
  }

The ModOrigin one will be used. Only if there is no ModOrigin or
ModHidden entry will the ModUnusable error be printed. See T21097 for an
example printing several reasons why an import is unusable.

- - - - -
17924162 by Krzysztof Gogolewski at 2023-11-16T07:27:36-05:00
Fix IPE test

A helper function was defined in a different module than used.
To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe

- - - - -


30 changed files:

- compiler/GHC/Iface/Errors/Ppr.hs
- compiler/GHC/Iface/Errors/Types.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/State.hs
- docs/users_guide/extending_ghc.rst
- docs/users_guide/exts/data_kinds.rst
- docs/users_guide/exts/linear_types.rst
- docs/users_guide/exts/primitives.rst
- docs/users_guide/exts/representation_polymorphism.rst
- docs/users_guide/using-warnings.rst
- + testsuite/tests/driver/T21097/Makefile
- + testsuite/tests/driver/T21097/T21097.stderr
- + testsuite/tests/driver/T21097/Test.hs
- + testsuite/tests/driver/T21097/all.T
- + testsuite/tests/driver/T21097/pkgdb/a.conf
- + testsuite/tests/driver/T21097/pkgdb/b.conf
- + testsuite/tests/driver/T21097/pkgdb/c.conf
- + testsuite/tests/driver/T21097b/Makefile
- + testsuite/tests/driver/T21097b/T21097b.stdout
- + testsuite/tests/driver/T21097b/Test.hs
- + testsuite/tests/driver/T21097b/all.T
- + testsuite/tests/driver/T21097b/pkgdb/a.conf
- + testsuite/tests/driver/T21097b/pkgdb/b.conf
- + testsuite/tests/driver/T21097b/pkgdb/c.conf
- + testsuite/tests/polykinds/T24083a.hs
- testsuite/tests/polykinds/all.T
- testsuite/tests/rts/all.T
- testsuite/tests/rts/ipe/all.T


Changes:

=====================================
compiler/GHC/Iface/Errors/Ppr.hs
=====================================
@@ -279,9 +279,10 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
     mod_hidden pkg =
         text "it is a hidden module in the package" <+> quotes (ppr pkg)
 
-    unusable (pkg, reason)
-      = text "It is a member of the package"
-      <+> quotes (ppr pkg)
+    unusable (UnusableUnit unit reason reexport)
+      = text "It is " <> (if reexport then text "reexported from the package"
+                                      else text "a member of the package")
+      <+> quotes (ppr unit)
       $$ pprReason (text "which is") reason
 
 


=====================================
compiler/GHC/Iface/Errors/Types.hs
=====================================
@@ -25,7 +25,7 @@ import GHC.Prelude
 import GHC.Types.Name (Name)
 import GHC.Types.TyThing (TyThing)
 import GHC.Unit.Types (Module, InstalledModule, UnitId, Unit)
-import GHC.Unit.State (UnitState, ModuleSuggestion, ModuleOrigin, UnusableUnitReason, UnitInfo)
+import GHC.Unit.State (UnitState, ModuleSuggestion, ModuleOrigin, UnusableUnit, UnitInfo)
 import GHC.Exception.Type (SomeException)
 import GHC.Unit.Types ( IsBootInterface )
 import Language.Haskell.Syntax.Module.Name ( ModuleName )
@@ -80,7 +80,7 @@ data CantFindInstalledReason
   | CouldntFindInFiles [FilePath]
   | GenericMissing
       [(Unit, Maybe UnitInfo)] [Unit]
-      [(Unit, UnusableUnitReason)] [FilePath]
+      [UnusableUnit] [FilePath]
   | MultiplePackages [(Module, ModuleOrigin)]
   deriving Generic
 


=====================================
compiler/GHC/Tc/Gen/HsType.hs
=====================================
@@ -2569,23 +2569,19 @@ kcCheckDeclHeader_sig sig_kind name flav
                    -- extended with both 'implicit_tcv_prs' and 'explicit_tv_prs'.
                    --
                    -- Also see Note [Arity of type families and type synonyms]
-                 ; ctx_k <- kc_res_ki
+                 ; res_kind :: ContextKind <- kc_res_ki
 
                  ; let sig_res_kind' = mkTyConKind excess_sig_tcbs sig_res_kind
 
                  ; traceTc "kcCheckDeclHeader_sig 2" $
                     vcat [ text "excess_sig_tcbs" <+> ppr excess_sig_tcbs
-                         , text "ctx_k" <+> ppr ctx_k
+                         , text "res_kind" <+> ppr res_kind
                          , text "sig_res_kind'" <+> ppr sig_res_kind'
                          ]
 
-                 -- Unify res_ki (from the type declaration) with the residual kind from
-                 -- the kind signature. Don't forget to apply the skolemising 'subst' first.
-                 ; case ctx_k of
-                      AnyKind -> return ()   -- No signature
-                      _ -> do
-                        res_ki <- newExpectedKind ctx_k
-                        check_exp_res_ki sig_res_kind' res_ki
+                 -- Unify res_ki (from the type declaration) with
+                 -- sig_res_kind', the residual kind from the kind signature.
+                 ; checkExpectedResKind sig_res_kind' res_kind
 
                  -- Add more binders for data/newtype, so the result kind has no arrows
                  -- See Note [Datatype return kinds]
@@ -2608,7 +2604,7 @@ kcCheckDeclHeader_sig sig_kind name flav
         ; implicit_tvs <- liftZonkM $ zonkTcTyVarsToTcTyVars implicit_tvs
         ; let implicit_prs = implicit_nms `zip` implicit_tvs
         ; checkForDuplicateScopedTyVars implicit_prs
-        ; checkForDisconnectedScopedTyVars all_tcbs implicit_prs
+        ; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs
 
         -- Swizzle the Names so that the TyCon uses the user-declared implicit names
         -- E.g  type T :: k -> Type
@@ -2650,18 +2646,23 @@ kcCheckDeclHeader_sig sig_kind name flav
 -- | Check the result kind annotation on a type constructor against
 -- the corresponding section of the standalone kind signature.
 -- Drops invisible binders that interfere with unification.
-check_exp_res_ki :: TcKind    -- ^ the actual kind
-                 -> TcKind    -- ^ the expected kind
-                 -> TcM ()
-check_exp_res_ki act_kind exp_kind
-  = discardResult $ unifyKind Nothing act_kind' exp_kind
-    where
-      (_, act_kind') = splitInvisPiTysN n_to_inst act_kind
+checkExpectedResKind :: TcKind       -- ^ the result kind from the separate kind signature
+                     -> ContextKind  -- ^ the result kind from the declaration header
+                     -> TcM ()
+checkExpectedResKind _ AnyKind
+  = return ()  -- No signature in the declaration header
+checkExpectedResKind sig_kind res_ki
+  = do { actual_res_ki <- newExpectedKind res_ki
 
-      -- by analogy with checkExpectedKind
-      n_exp_invis_bndrs = invisibleTyBndrCount exp_kind
-      n_act_invis_bndrs = invisibleTyBndrCount act_kind
-      n_to_inst         = n_act_invis_bndrs - n_exp_invis_bndrs
+       ; let -- Drop invisible binders from sig_kind until they match up
+             -- with res_ki.  By analogy with checkExpectedKind.
+             n_res_invis_bndrs = invisibleTyBndrCount actual_res_ki
+             n_sig_invis_bndrs = invisibleTyBndrCount sig_kind
+             n_to_inst         = n_sig_invis_bndrs - n_res_invis_bndrs
+
+             (_, sig_kind') = splitInvisPiTysN n_to_inst sig_kind
+
+       ; discardResult $ unifyKind Nothing sig_kind' actual_res_ki }
 
 matchUpSigWithDecl
   :: Name                        -- Name of the type constructor for error messages
@@ -2964,13 +2965,16 @@ expectedKindInCtxt _                   = OpenKind
 *                                                                      *
 ********************************************************************* -}
 
-checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM ()
+checkForDisconnectedScopedTyVars :: TyConFlavour TyCon -> [TcTyConBinder]
+                                 -> [(Name,TcTyVar)] -> TcM ()
 -- See Note [Disconnected type variables]
 -- `scoped_prs` is the mapping gotten by unifying
 --    - the standalone kind signature for T, with
 --    - the header of the type/class declaration for T
-checkForDisconnectedScopedTyVars sig_tcbs scoped_prs
-  = mapM_ report_disconnected (filterOut ok scoped_prs)
+checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs
+  = when (needsEtaExpansion flav) $
+         -- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables]
+    mapM_ report_disconnected (filterOut ok scoped_prs)
   where
     sig_tvs = mkVarSet (binderVars sig_tcbs)
     ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs
@@ -3047,6 +3051,25 @@ phantom synonym that just discards its argument.  So our plan is this:
 See #24083 for dicussion of alternatives, none satisfactory.  Also the fix is
 easy: just add an explicit `@kk` parameter to the declaration, to bind `kk`
 explicitly, rather than binding it implicitly via unification.
+
+(DTV1) We only want to make this check when there /are/ scoped type variables; and
+  that is determined by needsEtaExpansion.  Examples:
+
+     type C :: x -> y -> Constraint
+     class C a :: b -> Constraint where { ... }
+     -- The a,b scope over the "..."
+
+     type D :: forall k. k -> Type
+     data family D :: kk -> Type
+     -- Nothing for `kk` to scope over!
+
+  In the latter data-family case, the match-up stuff in kcCheckDeclHeader_sig will
+  return [] for `extra_tcbs`, and in fact `all_tcbs` will be empty.  So if we do
+  the check-for-disconnected-tyvars check we'll complain that `kk` is not bound
+  to one of `all_tcbs` (see #24083, comments about the `singletons` package).
+
+  The scoped-tyvar stuff is needed precisely for data/class/newtype declarations,
+  where needsEtaExpansion is True.
 -}
 
 {- *********************************************************************


=====================================
compiler/GHC/Unit/Finder.hs
=====================================
@@ -301,7 +301,7 @@ findLookupResult fc fopts r = case r of
                        , fr_suggestions = [] })
      LookupUnusable unusable ->
        let unusables' = map get_unusable unusable
-           get_unusable (m, ModUnusable r) = (moduleUnit m, r)
+           get_unusable (_, ModUnusable r) = r
            get_unusable (_, r)             =
              pprPanic "findLookupResult: unexpected origin" (ppr r)
        in return (NotFound{ fr_paths = [], fr_pkg = Nothing


=====================================
compiler/GHC/Unit/Finder/Types.hs
=====================================
@@ -61,7 +61,7 @@ data FindResult
                                            --   but the *unit* is hidden
 
         -- | Module is in these units, but it is unusable
-      , fr_unusables   :: [(Unit, UnusableUnitReason)]
+      , fr_unusables   :: [UnusableUnit]
 
       , fr_suggestions :: [ModuleSuggestion] -- ^ Possible mis-spelled modules
       }


=====================================
compiler/GHC/Unit/State.hs
=====================================
@@ -43,6 +43,7 @@ module GHC.Unit.State (
         LookupResult(..),
         ModuleSuggestion(..),
         ModuleOrigin(..),
+        UnusableUnit(..),
         UnusableUnitReason(..),
         pprReason,
 
@@ -173,8 +174,10 @@ data ModuleOrigin =
     -- (But maybe the user didn't realize), so we'll still keep track
     -- of these modules.)
     ModHidden
-    -- | Module is unavailable because the package is unusable.
-  | ModUnusable UnusableUnitReason
+
+    -- | Module is unavailable because the unit is unusable.
+  | ModUnusable !UnusableUnit
+
     -- | Module is public, and could have come from some places.
   | ModOrigin {
         -- | @Just False@ means that this module is in
@@ -192,6 +195,13 @@ data ModuleOrigin =
       , fromPackageFlag :: Bool
       }
 
+-- | A unusable unit module origin
+data UnusableUnit = UnusableUnit
+  { uuUnit        :: !Unit               -- ^ Unusable unit
+  , uuReason      :: !UnusableUnitReason -- ^ Reason
+  , uuIsReexport  :: !Bool               -- ^ Is the "module" a reexport?
+  }
+
 instance Outputable ModuleOrigin where
     ppr ModHidden = text "hidden module"
     ppr (ModUnusable _) = text "unusable module"
@@ -236,7 +246,8 @@ instance Semigroup ModuleOrigin where
                     text "x: " <> ppr x $$ text "y: " <> ppr y
             g Nothing x = x
             g x Nothing = x
-    x <> y = pprPanic "ModOrigin: hidden module redefined" $
+
+    x <> y = pprPanic "ModOrigin: module origin mismatch" $
                  text "x: " <> ppr x $$ text "y: " <> ppr y
 
 instance Monoid ModuleOrigin where
@@ -1818,21 +1829,36 @@ mkUnusableModuleNameProvidersMap :: UnusableUnits -> ModuleNameProvidersMap
 mkUnusableModuleNameProvidersMap unusables =
     nonDetFoldUniqMap extend_modmap emptyUniqMap unusables
  where
-    extend_modmap (_uid, (pkg, reason)) modmap = addListTo modmap bindings
+    extend_modmap (_uid, (unit_info, reason)) modmap = addListTo modmap bindings
       where bindings :: [(ModuleName, UniqMap Module ModuleOrigin)]
             bindings = exposed ++ hidden
 
-            origin = ModUnusable reason
-            pkg_id = mkUnit pkg
+            origin_reexport =  ModUnusable (UnusableUnit unit reason True)
+            origin_normal   =  ModUnusable (UnusableUnit unit reason False)
+            unit = mkUnit unit_info
 
             exposed = map get_exposed exposed_mods
-            hidden = [(m, mkModMap pkg_id m origin) | m <- hidden_mods]
-
-            get_exposed (mod, Just mod') = (mod, unitUniqMap mod' origin)
-            get_exposed (mod, _)         = (mod, mkModMap pkg_id mod origin)
-
-            exposed_mods = unitExposedModules pkg
-            hidden_mods  = unitHiddenModules pkg
+            hidden = [(m, mkModMap unit m origin_normal) | m <- hidden_mods]
+
+            -- with re-exports, c:Foo can be reexported from two (or more)
+            -- unusable packages:
+            --  Foo -> a:Foo (unusable reason A) -> c:Foo
+            --      -> b:Foo (unusable reason B) -> c:Foo
+            --
+            -- We must be careful to not record the following (#21097):
+            --  Foo -> c:Foo (unusable reason A)
+            --      -> c:Foo (unusable reason B)
+            -- But:
+            --  Foo -> a:Foo (unusable reason A)
+            --      -> b:Foo (unusable reason B)
+            --
+            get_exposed (mod, Just _) = (mod, mkModMap unit mod origin_reexport)
+            get_exposed (mod, _) = (mod, mkModMap unit mod origin_normal)
+              -- in the reexport case, we create a virtual module that doesn't
+              -- exist but we don't care as it's only used as a key in the map.
+
+            exposed_mods = unitExposedModules unit_info
+            hidden_mods  = unitHiddenModules  unit_info
 
 -- | Add a list of key/value pairs to a nested map.
 --


=====================================
docs/users_guide/extending_ghc.rst
=====================================
@@ -1383,6 +1383,7 @@ The plugin has type ``WantedConstraints -> [DefaultingProposal]``.
 * It is given the currently unsolved constraints.
 * It returns a list of independent "defaulting proposals".
 * Each proposal of type ``DefaultingProposal`` specifies:
+
   * ``deProposals``: specifies a list,
     in priority order, of sets of type variable assignments
   * ``deProposalCts :: [Ct]`` gives a set of constraints (always a


=====================================
docs/users_guide/exts/data_kinds.rst
=====================================
@@ -100,13 +100,13 @@ The following kinds and promoted data constructors can be used even when
 :extension:`DataKinds` is not enabled:
 
 - ``Type``
-- ``TYPE`` (see :ref:`_runtime-rep`)
+- ``TYPE`` (see :ref:`runtime-rep`)
 - ``Constraint`` (see :ref:`constraint-kind`)
 - ``CONSTRAINT``
 - ``Multiplicity`` and its promoted data constructors (see :extension:`LinearTypes`)
-- ``LiftedRep`` (see :ref:`_runtime-rep`)
-- ``RuntimeRep`` and its promoted data constructors (see :ref:`_runtime-rep`)
-- ``Levity`` and its promoted data constructors (see :ref:`_runtime-rep`)
+- ``LiftedRep`` (see :ref:`runtime-rep`)
+- ``RuntimeRep`` and its promoted data constructors (see :ref:`runtime-rep`)
+- ``Levity`` and its promoted data constructors (see :ref:`runtime-rep`)
 - ``VecCount`` and its promoted data constructors
 - ``VecElem`` and its promoted data constructors
 
@@ -231,7 +231,7 @@ See also :ghc-ticket:`7347`.
 :extension:`DataKinds` and type synonyms
 ----------------------------------------
 
-The :extensions:`DataKinds` extension interacts with type synonyms in the
+The :extension:`DataKinds` extension interacts with type synonyms in the
 following ways:
 
 1. In a *type* context: :extension:`DataKinds` is not required to use a type


=====================================
docs/users_guide/exts/linear_types.rst
=====================================
@@ -1,3 +1,5 @@
+.. _linear-types:
+
 Linear types
 ============
 
@@ -58,7 +60,8 @@ partially. See, however :ref:`linear-types-limitations`.
 Linear and multiplicity-polymorphic arrows are *always declared*,
 never inferred. That is, if you don't give an appropriate type
 signature to a function, it will be inferred as being a regular
-function of type ``a -> b``.
+function of type ``a -> b``. The same principle holds for
+representation polymorphism (see :ref:`representation-polymorphism-defaulting`).
 
 Data types
 ----------


=====================================
docs/users_guide/exts/primitives.rst
=====================================
@@ -438,7 +438,7 @@ You may even declare levity-polymorphic data types: ::
 While ``f`` above could reasonably be levity-polymorphic (as it evaluates its
 argument either way), GHC currently disallows the more general type
 ``PEither @l Int Bool -> Bool``. This is a consequence of the
-`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__,
+`representation-polymorphic binder restriction <#representation-polymorphism-restrictions>`__.
 
 Pattern matching against an unlifted data type work just like that for lifted
 types; but see :ref:`recursive-and-polymorphic-let-bindings` for the semantics of


=====================================
docs/users_guide/exts/representation_polymorphism.rst
=====================================
@@ -108,6 +108,35 @@ These functions do not bind a representation-polymorphic variable, and
 so are accepted. Their polymorphism allows users to use these to conveniently
 stub out functions that return unboxed types.
 
+.. _representation-polymorphism-defaulting:
+
+Inference and defaulting
+------------------------
+
+GHC does not infer representation-polymorphic types.
+If the representation of a variable is not specified, it will be assumed
+to be ``LiftedRep``.
+For example, if you write ``f a b = a b``, the inferred type of ``f``
+will be ::
+
+  f :: forall {a :: Type} {b :: Type}. (a -> b) -> a -> b
+
+even though ::
+
+  f :: forall {rep} {a :: Type} {b :: TYPE rep}. (a -> b) -> a -> b
+
+would also be legal, as described above.
+
+Likewise, in a user-written signature ``f :: forall a b. (a -> b) -> a -> b``
+GHC will assume that both ``a`` and ``b`` have kind ``Type``. To use
+a different representation, you have to specify the kinds of ``a`` and ``b``.
+
+During type inference, GHC does not quantify over variables of kind
+``RuntimeRep`` nor ``Levity``.
+Instead, they are defaulted to ``LiftedRep`` and ``Lifted`` respectively.
+Likewise, ``Multiplicity`` variables (:ref:`linear-types`) are defaulted
+to ``Many``.
+
 .. _printing-representation-polymorphic-types:
 
 Printing representation-polymorphic types


=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -2574,7 +2574,7 @@ of ``-W(no-)*``.
     Introduced in GHC 9.10.1, this warns when an illegal use of a type or kind
     (without having enabled the :extension:`DataKinds` extension) is caught in
     the typechecker (hence the ``-tc`` suffix). These warnings complement the
-    existing :extensions:`DataKinds` checks (that have existed since
+    existing :extension:`DataKinds` checks (that have existed since
     :extension:`DataKinds` was first introduced), which result in errors
     instead of warnings.
 


=====================================
testsuite/tests/driver/T21097/Makefile
=====================================
@@ -0,0 +1,7 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T21097:
+	'$(GHC_PKG)' recache --package-db pkgdb
+	- '$(TEST_HC)' -package-db pkgdb -v0 Test.hs; test $$? -eq 2


=====================================
testsuite/tests/driver/T21097/T21097.stderr
=====================================
@@ -0,0 +1,16 @@
+
+Test.hs:3:1: error: [GHC-87110]
+    Could not load module ‘Foo’.
+    It is a member of the package ‘c-0.1’
+    which is unusable due to missing dependencies:
+      d-0.1
+    It is reexported from the package ‘b-0.1’
+    which is unusable due to missing dependencies:
+      c-0.1
+    It is reexported from the package ‘a-0.1’
+    which is unusable due to missing dependencies:
+      c-0.1
+    Use -v to see a list of the files searched for.
+  |
+3 | import Foo
+  | ^^^^^^^^^^


=====================================
testsuite/tests/driver/T21097/Test.hs
=====================================
@@ -0,0 +1,3 @@
+module Main where
+
+import Foo


=====================================
testsuite/tests/driver/T21097/all.T
=====================================
@@ -0,0 +1,4 @@
+# Package a and b both depend on c which is broken (depends on non-existing d)
+test('T21097',
+  [ extra_files(["pkgdb", "pkgdb/a.conf", "pkgdb/b.conf", "pkgdb/c.conf", "Test.hs"])
+  ], makefile_test, [])


=====================================
testsuite/tests/driver/T21097/pkgdb/a.conf
=====================================
@@ -0,0 +1,12 @@
+name:                 a
+version:              0.1
+visibility:           public
+id:                   a-0.1
+key:                  a-0.1
+abi:                  4e313a9f18a8df7d71cc2283205935c4
+exposed:              True
+
+exposed-modules:
+  Foo from c-0.1:Foo
+
+depends: c-0.1


=====================================
testsuite/tests/driver/T21097/pkgdb/b.conf
=====================================
@@ -0,0 +1,12 @@
+name:                 b
+version:              0.1
+visibility:           public
+id:                   b-0.1
+key:                  b-0.1
+abi:                  4e313a9f18a8df7d71cc2283205935c4
+exposed:              True
+
+exposed-modules:
+  Foo from c-0.1:Foo
+
+depends:              c-0.1


=====================================
testsuite/tests/driver/T21097/pkgdb/c.conf
=====================================
@@ -0,0 +1,12 @@
+name:                 c
+version:              0.1
+visibility:           public
+id:                   c-0.1
+key:                  c-0.1
+abi:                  4e313a9f18a8df7d71cc2283205935c4
+exposed:              True
+
+exposed-modules:
+  Foo
+
+depends: d-0.1


=====================================
testsuite/tests/driver/T21097b/Makefile
=====================================
@@ -0,0 +1,7 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T21097b:
+	'$(GHC_PKG)' recache --package-db pkgdb
+	'$(TEST_HC)' -no-global-package-db -no-user-package-db -package-db pkgdb -v0 Test.hs -ddump-mod-map


=====================================
testsuite/tests/driver/T21097b/T21097b.stdout
=====================================
@@ -0,0 +1,5 @@
+
+==================== Module Map ====================
+Foo                                               a-0.1 (exposed package)
+
+


=====================================
testsuite/tests/driver/T21097b/Test.hs
=====================================
@@ -0,0 +1,3 @@
+module Main where
+
+import Foo


=====================================
testsuite/tests/driver/T21097b/all.T
=====================================
@@ -0,0 +1,6 @@
+# Package b is unusable (broken dependency) and reexport Foo from a (which is usable)
+test('T21097b',
+  [ extra_files(["pkgdb", "pkgdb/a.conf", "pkgdb/b.conf", "Test.hs"])
+  , ignore_stderr
+  , exit_code(2)
+  ], makefile_test, [])


=====================================
testsuite/tests/driver/T21097b/pkgdb/a.conf
=====================================
@@ -0,0 +1,10 @@
+name:                 a
+version:              0.1
+visibility:           public
+id:                   a-0.1
+key:                  a-0.1
+abi:                  4e313a9f18a8df7d71cc2283205935c4
+exposed:              True
+
+exposed-modules:
+  Foo


=====================================
testsuite/tests/driver/T21097b/pkgdb/b.conf
=====================================
@@ -0,0 +1,12 @@
+name:                 b
+version:              0.1
+visibility:           public
+id:                   b-0.1
+key:                  b-0.1
+abi:                  4e313a9f18a8df7d71cc2283205935c4
+exposed:              True
+
+exposed-modules:
+  Foo from a-0.1:Foo
+
+depends: a-0.1, missing-0.1


=====================================
testsuite/tests/driver/T21097b/pkgdb/c.conf
=====================================
@@ -0,0 +1,12 @@
+name:                 c
+version:              0.1
+visibility:           public
+id:                   c-0.1
+key:                  c-0.1
+abi:                  4e313a9f18a8df7d71cc2283205935c4
+exposed:              True
+
+exposed-modules:
+  Foo
+
+depends: d-0.1


=====================================
testsuite/tests/polykinds/T24083a.hs
=====================================
@@ -0,0 +1,8 @@
+{-# LANGUAGE StandaloneKindSignatures #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE ScopedTypeVariables, RankNTypes #-}
+
+module T24083a where
+
+type TyCon :: (k1 -> k2) -> unmatchable_fun
+data family TyCon :: (k1 -> k2) -> unmatchable_fun


=====================================
testsuite/tests/polykinds/all.T
=====================================
@@ -244,3 +244,4 @@ test('T22743', normal, compile_fail, [''])
 test('T22742', normal, compile_fail, [''])
 test('T22793', normal, compile_fail, [''])
 test('T24083', normal, compile_fail, [''])
+test('T24083a', normal, compile, [''])


=====================================
testsuite/tests/rts/all.T
=====================================
@@ -216,10 +216,6 @@ test('EventlogOutput_IPE',
      ],
      makefile_test, ['EventlogOutput_IPE'])
 
-# Remove the capability prefix from IPE event log lines.
-def noCapabilityOutputFilter(s):
-     return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s)
-
 test('T4059', req_c, makefile_test, ['T4059'])
 
 # Test for #4274


=====================================
testsuite/tests/rts/ipe/all.T
=====================================
@@ -1,3 +1,7 @@
+# Remove the capability prefix from IPE event log lines.
+def noCapabilityOutputFilter(s):
+     return re.sub(r'[a-f0-9]+: IPE:', 'IPE:', s)
+
 test('ipeMap', [extra_files(['ipe_lib.c', 'ipe_lib.h']), c_src, omit_ghci], compile_and_run, ['ipe_lib.c'])
 
 # Manually create IPE entries and dump them to event log (stderr).



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2325536a245eece7c96fc615a20523127c12047...17924162f6d59ba32b22871b2abad7985d75e3b4

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2325536a245eece7c96fc615a20523127c12047...17924162f6d59ba32b22871b2abad7985d75e3b4
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/20231116/b3abd81b/attachment-0001.html>


More information about the ghc-commits mailing list