Do primop rep-poly checks when instantiating
This patch changes how we perform representation-polymorphism checking for primops (and other wired-in Ids such as coerce). When instantiating the primop, we check whether each type variable is required to instantiated to a concrete type, and if so we create a new concrete metavariable (a ConcreteTv) instead of a simple MetaTv. (A little subtlety is the need to apply the substitution obtained from instantiating to the ConcreteTvOrigins, see Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.) This allows us to prevent representation-polymorphism in non-argument position, as that is required for some of these primops. We can also remove the logic in tcRemainingValArgs, except for the part concerning representation-polymorphic unlifted newtypes. The function has been renamed rejectRepPolyNewtypes; all it does now is reject unsaturated occurrences of representation-polymorphic newtype constructors when the representation of its argument isn't a concrete RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check). The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head gives more explanation about a possible path to PHASE 2, which would be in line with the treatment for primops taken in this patch. We also update the Core Lint check to handle this new framework. This means Core Lint now checks representation-polymorphism in continuation position like needed for catch#. Fixes #21906 ------------------------- Metric Increase: LargeRecord -------------------------
Showing
- compiler/GHC/Builtin/PrimOps.hs 1 addition, 1 deletioncompiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/PrimOps/Ids.hs 98 additions, 4 deletionscompiler/GHC/Builtin/PrimOps/Ids.hs
- compiler/GHC/Builtin/Types.hs 68 additions, 30 deletionscompiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/primops.txt.pp 130 additions, 134 deletionscompiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Core.hs 15 additions, 22 deletionscompiler/GHC/Core.hs
- compiler/GHC/Core/DataCon.hs 26 additions, 3 deletionscompiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/Lint.hs 190 additions, 97 deletionscompiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs 6 additions, 3 deletionscompiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/TyCo/Subst.hs 8 additions, 8 deletionscompiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Type.hs 1 addition, 14 deletionscompiler/GHC/Core/Type.hs
- compiler/GHC/Driver/Config/Core/Lint.hs 1 addition, 2 deletionscompiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/HsToCore.hs 7 additions, 1 deletioncompiler/GHC/HsToCore.hs
- compiler/GHC/Tc/Errors.hs 10 additions, 2 deletionscompiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs 2 additions, 2 deletionscompiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs 108 additions, 26 deletionscompiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Expr.hs 47 additions, 24 deletionscompiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs 264 additions, 238 deletionscompiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Sig.hs 0 additions, 1 deletioncompiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Solver/Equality.hs 2 additions, 2 deletionscompiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/TyCl/Build.hs 3 additions, 1 deletioncompiler/GHC/Tc/TyCl/Build.hs
Loading
Please register or sign in to comment