[Git][ghc/ghc][wip/T24817a] Andd ZonkAny and document it

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Mon Sep 9 15:27:12 UTC 2024



Simon Peyton Jones pushed to branch wip/T24817a at Glasgow Haskell Compiler / GHC


Commits:
68b9f806 by Simon Peyton Jones at 2024-09-09T16:26:51+01:00
Andd ZonkAny and document it

This MR fixed #24817 by adding ZonkAny, which takes a Nat
argument.

See Note [Any types] in GHC.Builtin.Types, especially
wrinkle (Any4).

- - - - -


12 changed files:

- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Zonk/Type.hs
- testsuite/tests/perf/compiler/T11068.stdout
- + testsuite/tests/pmcheck/should_compile/T24817.hs
- testsuite/tests/pmcheck/should_compile/all.T
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/profiling/should_run/staticcallstack002.stdout
- testsuite/tests/simplCore/should_compile/T13156.stdout
- testsuite/tests/typecheck/should_fail/T13292.stderr


Changes:

=====================================
compiler/GHC/Builtin/Names.hs
=====================================
@@ -2007,6 +2007,12 @@ uWordTyConKey   = mkPreludeTyConUnique 163
 unsatisfiableClassNameKey :: Unique
 unsatisfiableClassNameKey = mkPreludeTyConUnique 170
 
+anyTyConKey :: Unique
+anyTyConKey = mkPreludeTyConUnique 171
+
+zonkAnyTyConKey :: Unique
+zonkAnyTyConKey = mkPreludeTyConUnique 172
+
 -- Custom user type-errors
 errorMessageTypeErrorFamKey :: Unique
 errorMessageTypeErrorFamKey = mkPreludeTyConUnique 181
@@ -2020,9 +2026,6 @@ proxyPrimTyConKey = mkPreludeTyConUnique 184
 specTyConKey :: Unique
 specTyConKey = mkPreludeTyConUnique 185
 
-anyTyConKey :: Unique
-anyTyConKey = mkPreludeTyConUnique 186
-
 smallArrayPrimTyConKey        = mkPreludeTyConUnique  187
 smallMutableArrayPrimTyConKey = mkPreludeTyConUnique  188
 


=====================================
compiler/GHC/Builtin/Types.hs
=====================================
@@ -91,7 +91,7 @@ module GHC.Builtin.Types (
         cTupleSelId, cTupleSelIdName,
 
         -- * Any
-        anyTyCon, anyTy, anyTypeOfKind,
+        anyTyCon, anyTy, anyTypeOfKind, zonkAnyTyCon,
 
         -- * Recovery TyCon
         makeRecoveryTyCon,
@@ -184,7 +184,7 @@ import GHC.Core.ConLike
 import GHC.Core.TyCon
 import GHC.Core.Class     ( Class, mkClass )
 import GHC.Core.Map.Type  ( TypeMap, emptyTypeMap, extendTypeMap, lookupTypeMap )
-import qualified GHC.Core.TyCo.Rep as TyCoRep (Type(TyConApp))
+import qualified GHC.Core.TyCo.Rep as TyCoRep ( Type(TyConApp) )
 
 import GHC.Types.TyThing
 import GHC.Types.SourceText
@@ -309,6 +309,7 @@ wiredInTyCons = map (dataConTyCon . snd) boxingDataCons
                 , soloTyCon
 
                 , anyTyCon
+                , zonkAnyTyCon
                 , boolTyCon
                 , charTyCon
                 , stringTyCon
@@ -419,65 +420,102 @@ doubleDataConName  = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "D#")
 {-
 Note [Any types]
 ~~~~~~~~~~~~~~~~
-The type constructor Any,
+The type constructors `Any` and `ZonkAny` are closed type families declared thus:
 
-    type family Any :: k where { }
+    type family Any     :: forall k.        k where { }
+    type family ZonkAny :: forall k. Nat -> k where { }
 
-It has these properties:
+They are used when we want a type of a particular kind, but we don't really care
+what that type is.  The leading example is this: `ZonkAny` is used to instantiate
+un-constrained type variables after type checking. For example, consider the
+term (length [] :: Int), where
 
-  * Note that 'Any' is kind polymorphic since in some program we may
-    need to use Any to fill in a type variable of some kind other than *
-    (see #959 for examples).  Its kind is thus `forall k. k``.
+  length :: forall a. [a] -> Int
+  []     :: forall a. [a]
 
-  * It is defined in module GHC.Types, and exported so that it is
-    available to users.  For this reason it's treated like any other
-    wired-in type:
-      - has a fixed unique, anyTyConKey,
-      - lives in the global name cache
+We must type-apply `length` and `[]`, but to what type? It doesn't matter!
+The typechecker will end up with
 
-  * It is a *closed* type family, with no instances.  This means that
-    if   ty :: '(k1, k2)  we add a given coercion
-             g :: ty ~ (Fst ty, Snd ty)
-    If Any was a *data* type, then we'd get inconsistency because 'ty'
-    could be (Any '(k1,k2)) and then we'd have an equality with Any on
-    one side and '(,) on the other. See also #9097 and #9636.
+  length @alpha ([] @alpha)
 
-  * When instantiated at a lifted type it is inhabited by at least one value,
-    namely bottom
+where `alpha` is an un-constrained unification variable.  The "zonking" process zaps
+that unconstrained `alpha` to an arbitrary type (ZonkAny @Type 3), where the `3` is
+arbitrary (see wrinkle (Any5) below).  This is done in `GHC.Tc.Zonk.Type.commitFlexi`.
+So we end up with
 
-  * You can safely coerce any /lifted/ type to Any and back with unsafeCoerce.
-    You can safely coerce any /unlifted/ type to Any and back with unsafeCoerceUnlifted.
-    You can coerce /any/ type to Any and back with unsafeCoerce#, but it's only safe when
-    the kinds of both the type and Any match.
+  length @(ZonkAny @Type 3) ([] @(ZonkAny @Type 3))
 
-    For lifted/unlifted types unsafeCoerce[Unlifted] should be preferred over unsafeCoerce#
-    as they prevent accidentally coercing between types with kinds that don't match.
+`Any` and `ZonkAny` differ only in the presence of the `Nat` argument; see
+wrinkle (Any4).
 
-    See examples in ghc-prim:GHC.Types
+Wrinkles:
 
-  * It does not claim to be a *data* type, and that's important for
-    the code generator, because the code gen may *enter* a data value
-    but never enters a function value.
+(Any1) `Any` and `ZonkAny` are kind polymorphic since in some program we may
+   need to use `ZonkAny` to fill in a type variable of some kind other than *
+   (see #959 for examples).
 
-  * It is wired-in so we can easily refer to it where we don't have a name
-    environment (e.g. see Rules.matchRule for one example)
+(Any2) They are /closed/ type families, with no instances.  For example, suppose that
+   with  alpha :: '(k1, k2)  we add a given coercion
+             g :: alpha ~ (Fst alpha, Snd alpha)
+   and we zonked alpha = ZonkAny @(k1,k2) n.  Then, if `ZonkAny` was a /data/ type,
+   we'd get inconsistency because we'd have a Given equality with `ZonkAny` on one
+   side and '(,) on the other. See also #9097 and #9636.
 
-It's used to instantiate un-constrained type variables after type checking. For
-example, 'length' has type
+   See #25244 for a suggestion that we instead use an /open/ type family for which
+   you cannot provide instances.  Probably the difference is not very important.
 
-  length :: forall a. [a] -> Int
+(Any3) They do not claim to be /data/ types, and that's important for
+   the code generator, because the code gen may /enter/ a data value
+   but never enters a function value.
+
+(Any4) `ZonkAny` takes a `Nat` argument so that we can readily make up /distinct/
+   types (#24817).  Consider
 
-and the list datacon for the empty list has type
+     data SBool a where { STrue :: SBool True; SFalse :: SBool False }
 
-  [] :: forall a. [a]
+     foo :: forall a b. (SBool a, SBool b)
 
-In order to compose these two terms as @length []@ a type
-application is required, but there is no constraint on the
-choice.  In this situation GHC uses 'Any',
+     bar :: Bool
+     bar = case foo @alpha @beta of
+             (STrue, SFalse) -> True   -- This branch is not inaccessible!
+             _               -> False
 
-> length @(Any @Type) ([] @(Any @Type))
+   Now, what are `alpha` and `beta`? If we zonk both of them to the same type
+   `Any @Type`, the pattern-match checker will (wrongly) report that the first
+   branch is inaccessible.  So we zonk them to two /different/ types:
+       alpha :=  ZonkAny @Type 4   and   beta :=  ZonkAny @Type k 5
+   (The actual numbers are arbitrary; they just need to differ.)
+
+   The unique-name generation comes from field `tcg_zany_n` of `TcGblEnv`; and
+   `GHC.Tc.Zonk.Type.commitFlexi` calls `GHC.Tc.Utils.Monad.newZonkAnyType` to
+   make up a fresh type.
+
+(Any5) `Any` and `ZonkAny` are wired-in so we can easily refer to it where we
+    don't have a name environment (e.g. see Rules.matchRule for one example)
+
+(Any6) `Any` is defined in library module ghc-prim:GHC.Types, and exported so that
+    it is available to users.  For this reason it's treated like any other
+    wired-in type:
+      - has a fixed unique, anyTyConKey,
+      - lives in the global name cache
+    Currently `ZonkAny` is not available to users; but it could easily be.
 
-Above, we print kinds explicitly, as if with -fprint-explicit-kinds.
+(Any7) Properties of `Any`:
+  * When `Any` is instantiated at a lifted type it is inhabited by at least one value,
+    namely bottom.
+
+  * You can safely coerce any /lifted/ type to `Any` and back with `unsafeCoerce`.
+
+  * You can safely coerce any /unlifted/ type to `Any` and back with `unsafeCoerceUnlifted`.
+
+  * You can coerce /any/ type to `Any` and back with `unsafeCoerce#`, but it's only safe when
+    the kinds of both the type and `Any` match.
+
+  * For lifted/unlifted types `unsafeCoerce[Unlifted]` should be preferred over
+    `unsafeCoerce#` as they prevent accidentally coercing between types with kinds
+    that don't match.
+
+    See examples in ghc-prim:GHC.Types
 
 The Any tycon used to be quite magic, but we have since been able to
 implement it merely with an empty kind polymorphic type family. See #10886 for a
@@ -490,6 +528,7 @@ anyTyConName =
     mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Any") anyTyConKey anyTyCon
 
 anyTyCon :: TyCon
+-- See Note [Any types]
 anyTyCon = mkFamilyTyCon anyTyConName binders res_kind Nothing
                          (ClosedSynFamilyTyCon Nothing)
                          Nothing
@@ -504,6 +543,24 @@ anyTy = mkTyConTy anyTyCon
 anyTypeOfKind :: Kind -> Type
 anyTypeOfKind kind = mkTyConApp anyTyCon [kind]
 
+zonkAnyTyConName :: Name
+zonkAnyTyConName =
+    mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "ZonkAny") zonkAnyTyConKey zonkAnyTyCon
+
+zonkAnyTyCon :: TyCon
+-- ZonkAnyTyCon :: forall k. Nat -> k
+-- See Note [Any types]
+zonkAnyTyCon = mkFamilyTyCon zonkAnyTyConName
+                         [ mkNamedTyConBinder Specified kv
+                         , mkAnonTyConBinder nat_kv ]
+                         (mkTyVarTy kv)
+                         Nothing
+                         (ClosedSynFamilyTyCon Nothing)
+                         Nothing
+                         NotInjective
+  where
+    [kv,nat_kv] = mkTemplateKindVars [liftedTypeKind, naturalTy]
+
 -- | Make a fake, recovery 'TyCon' from an existing one.
 -- Used when recovering from errors in type declarations
 makeRecoveryTyCon :: TyCon -> TyCon


=====================================
compiler/GHC/Tc/Types.hs
=====================================
@@ -567,6 +567,10 @@ data TcGblEnv
         tcg_dfun_n  :: TcRef OccSet,
           -- ^ Allows us to choose unique DFun names.
 
+        tcg_zany_n :: TcRef Integer,
+          -- ^ A source of unique identities for ZonkAny instances
+          -- See Note [Any types] in GHC.Builtin.Types, wrinkle (Any4)
+
         tcg_merged :: [(Module, Fingerprint)],
           -- ^ The requirements we merged with; we always have to recompile
           -- if any of these changed.


=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -142,7 +142,7 @@ module GHC.Tc.Utils.Monad(
   getCCIndexM, getCCIndexTcM,
 
   -- * Zonking
-  liftZonkM,
+  liftZonkM, newZonkAnyType,
 
   -- * Complete matches
   localAndImportedCompleteMatches, getCompleteMatchesTcM,
@@ -156,6 +156,7 @@ import GHC.Prelude
 
 
 import GHC.Builtin.Names
+import GHC.Builtin.Types( zonkAnyTyCon )
 
 import GHC.Tc.Errors.Types
 import GHC.Tc.Types     -- Re-export all
@@ -178,6 +179,7 @@ import GHC.Core.UsageEnv
 import GHC.Core.Multiplicity
 import GHC.Core.InstEnv
 import GHC.Core.FamInstEnv
+import GHC.Core.Type( mkNumLitTy )
 
 import GHC.Driver.Env
 import GHC.Driver.Session
@@ -258,6 +260,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this
         infer_var    <- newIORef True ;
         infer_reasons_var <- newIORef emptyMessages ;
         dfun_n_var   <- newIORef emptyOccSet ;
+        zany_n_var   <- newIORef 0 ;
         let { type_env_var = hsc_type_env_vars hsc_env };
 
         dependent_files_var <- newIORef [] ;
@@ -348,6 +351,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this
                 tcg_patsyns        = [],
                 tcg_merged         = [],
                 tcg_dfun_n         = dfun_n_var,
+                tcg_zany_n         = zany_n_var,
                 tcg_keep           = keep_var,
                 tcg_hdr_info        = (Nothing,Nothing),
                 tcg_hpc            = False,
@@ -1787,6 +1791,18 @@ chooseUniqueOccTc fn =
      ; writeTcRef dfun_n_var (extendOccSet set occ)
      ; return occ }
 
+newZonkAnyType :: Kind -> TcM Type
+-- Return a type (ZonkAny @k n), where n is fresh
+-- Recall  ZonkAny :: forall k. Natural -> k
+-- See Note [Any types] in GHC.Builtin.Types, wrinkle (Any4)
+newZonkAnyType kind
+  = do { env <- getGblEnv
+       ; let zany_n_var = tcg_zany_n env
+       ; i <- readTcRef zany_n_var
+       ; let !i2 = i+1
+       ; writeTcRef zany_n_var i2
+       ; return (mkTyConApp zonkAnyTyCon [kind, mkNumLitTy i]) }
+
 getConstraintVar :: TcM (TcRef WantedConstraints)
 getConstraintVar = do { env <- getLclEnv; return (tcl_lie env) }
 


=====================================
compiler/GHC/Tc/Zonk/Type.hs
=====================================
@@ -54,7 +54,7 @@ import GHC.Tc.Types.TcRef
 import GHC.Tc.TyCl.Build ( TcMethInfo, MethInfo )
 import GHC.Tc.Utils.Env ( tcLookupGlobalOnly )
 import GHC.Tc.Utils.TcType
-import GHC.Tc.Utils.Monad ( setSrcSpanA, liftZonkM, traceTc, addErr )
+import GHC.Tc.Utils.Monad ( newZonkAnyType, setSrcSpanA, liftZonkM, traceTc, addErr )
 import GHC.Tc.Types.Constraint
 import GHC.Tc.Types.Evidence
 import GHC.Tc.Errors.Types
@@ -469,8 +469,9 @@ commitFlexi tv zonked_kind
            -> do { addErr $ TcRnZonkerMessage (ZonkerCannotDefaultConcrete origin)
                  ; return (anyTypeOfKind zonked_kind) }
            | otherwise
-           -> do { traceTc "Defaulting flexi tyvar to Any:" (pprTyVar tv)
-                 ; return (anyTypeOfKind zonked_kind) }
+           -> do { traceTc "Defaulting flexi tyvar to ZonkAny:" (pprTyVar tv)
+                   -- See Note [Any types] in GHC.Builtin.Types, esp wrinkle (Any4)
+                 ; newZonkAnyType zonked_kind }
 
          RuntimeUnkFlexi
            -> do { traceTc "Defaulting flexi tyvar to RuntimeUnk:" (pprTyVar tv)


=====================================
testsuite/tests/perf/compiler/T11068.stdout
=====================================
@@ -23,137 +23,137 @@
                            `cast` (GHC.Internal.Generics.N:M1[0]
                            `cast` (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.L1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1
-      ((GHC.Internal.Generics.U1 @(*) @GHC.Types.Any)
+      ((GHC.Internal.Generics.U1 @(*) @(GHC.Types.ZonkAny 0))
        `cast` (Sym (GHC.Internal.Generics.N:M1[0]
   = GHC.Internal.Generics.R1
   = GHC.Internal.Generics.R1


=====================================
testsuite/tests/pmcheck/should_compile/T24817.hs
=====================================
@@ -0,0 +1,15 @@
+{-# LANGUAGE GADTs, DataKinds #-}
+
+module T24817 where
+
+data SBool b where
+  STrue :: SBool True
+  SFalse :: SBool False
+
+foo :: forall a b. (SBool a, SBool b)
+foo = error "urk"
+
+bar :: Bool
+bar = case foo of
+        (STrue, SFalse) -> True
+        _ -> False


=====================================
testsuite/tests/pmcheck/should_compile/all.T
=====================================
@@ -171,3 +171,4 @@ test('DsIncompleteRecSel1', normal, compile, ['-Wincomplete-record-selectors'])
 test('DsIncompleteRecSel2', normal, compile, ['-Wincomplete-record-selectors'])
 test('DsIncompleteRecSel3', [collect_compiler_stats('bytes allocated', 10)], compile, ['-Wincomplete-record-selectors'])
 test('DoubleMatch', normal, compile, [overlapping_incomplete])
+test('T24817', normal, compile, [overlapping_incomplete])


=====================================
testsuite/tests/printer/T17697.stderr
=====================================
@@ -1,7 +1,8 @@
-
 T17697.hs:6:5: warning: [GHC-88464] [-Wdeferred-out-of-scope-variables (in -Wdefault)]
     Variable not in scope: threadDelay :: t0 -> IO a0
 
 T17697.hs:6:5: warning: [GHC-81995] [-Wunused-do-bind (in -Wall)]
-    A do-notation statement discarded a result of type ‘GHC.Types.Any’
+    A do-notation statement discarded a result of type
+      ‘GHC.Types.ZonkAny 1’
     Suggested fix: Suppress this warning by saying ‘_ <- threadDelay 1’
+


=====================================
testsuite/tests/profiling/should_run/staticcallstack002.stdout
=====================================
@@ -1,4 +1,4 @@
-Just (InfoProv {ipName = "sat_s237_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "10:23-39"})
-Just (InfoProv {ipName = "sat_s23r_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "11:23-42"})
-Just (InfoProv {ipName = "sat_s23L_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "12:23-46"})
-Just (InfoProv {ipName = "sat_s245_info", ipDesc = THUNK, ipTyDesc = "Any", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "13:23-44"})
+Just (InfoProv {ipName = "sat_s1Rh_info", ipDesc = THUNK, ipTyDesc = "ZonkAny 0", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "10:23-39"})
+Just (InfoProv {ipName = "sat_s1RB_info", ipDesc = THUNK, ipTyDesc = "ZonkAny 1", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "11:23-42"})
+Just (InfoProv {ipName = "sat_s1RV_info", ipDesc = THUNK, ipTyDesc = "ZonkAny 2", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "12:23-46"})
+Just (InfoProv {ipName = "sat_s1Sf_info", ipDesc = THUNK, ipTyDesc = "ZonkAny 3", ipLabel = "main", ipUnitId = "main", ipMod = "Main", ipSrcFile = "staticcallstack002.hs", ipSrcSpan = "13:23-44"})


=====================================
testsuite/tests/simplCore/should_compile/T13156.stdout
=====================================
@@ -1 +1,2 @@
-      case r @GHC.Types.Any of { __DEFAULT -> r @a }
+      case r @(GHC.Types.ZonkAny 0) of { __DEFAULT ->
+      case r @(GHC.Types.ZonkAny 1) of { __DEFAULT -> r @a }


=====================================
testsuite/tests/typecheck/should_fail/T13292.stderr
=====================================
@@ -1,4 +1,3 @@
-
 T13292a.hs:4:12: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
     • Ambiguous type variable ‘m0’ arising from a use of ‘return’
       prevents the constraint ‘(Monad m0)’ from being solved.
@@ -15,14 +14,15 @@ T13292a.hs:4:12: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
       In an equation for ‘someFunc’: someFunc = return ()
 
 T13292.hs:6:1: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
-    • Couldn't match type ‘GHC.Types.Any’ with ‘IO’
+    • Couldn't match type ‘GHC.Types.ZonkAny 0’ with ‘IO’
       Expected: IO ()
-        Actual: GHC.Types.Any ()
+        Actual: GHC.Types.ZonkAny 0 ()
     • When checking the type of the IO action ‘main’
 
 T13292.hs:6:1: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
-    • Couldn't match type ‘GHC.Types.Any’ with ‘IO’
+    • Couldn't match type ‘GHC.Types.ZonkAny 0’ with ‘IO’
       Expected: IO ()
-        Actual: GHC.Types.Any ()
+        Actual: GHC.Types.ZonkAny 0 ()
     • In the expression: main
       When checking the type of the IO action ‘main’
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68b9f8063ff7f787d639ef530d3c1b9357333e08

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68b9f8063ff7f787d639ef530d3c1b9357333e08
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/20240909/2ab1c7b5/attachment-0001.html>


More information about the ghc-commits mailing list