Skip to content
Snippets Groups Projects
  1. Aug 09, 2023
  2. Jul 18, 2023
    • Krzysztof Gogolewski's avatar
      Core Lint: distinguish let and letrec in locations · 00648e5d
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      Lint messages were saying "in the body of letrec" even for non-recursive
      let.
      
      I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no
      separate letrec.
      00648e5d
    • sheaf's avatar
      Do primop rep-poly checks when instantiating · 889c2bbb
      sheaf authored and Marge Bot's avatar Marge Bot committed
      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
      -------------------------
      889c2bbb
  3. Feb 06, 2023
  4. Nov 29, 2022
  5. Oct 26, 2022
  6. Sep 13, 2022
    • sheaf's avatar
      Diagnostic codes: acccept test changes · 362cca13
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The testsuite output now contains diagnostic codes, so many tests need
      to be updated at once.
      We decided it was best to keep the diagnostic codes in the testsuite
      output, so that contributors don't inadvertently make changes to the
      diagnostic codes.
      362cca13
  7. Sep 01, 2022
    • Krzysztof Gogolewski's avatar
      Minor cleanup · 7d3a055d
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused),
        isCoVar_maybe (duplicated by getCoVar_maybe)
      - Replace a few occurrences of voidPrimId with (# #).
        void# is a deprecated synonym for the unboxed tuple.
      - Use showSDoc in :show linker.
        This makes it consistent with the other :show commands
      7d3a055d
  8. Aug 04, 2022
    • Yiyun Liu's avatar
      Remove TCvSubst and use Subst for both term and type-level subst · 35aef18d
      Yiyun Liu authored and Marge Bot's avatar Marge Bot committed
      This patch removes the TCvSubst data type and instead uses Subst as
      the environment for both term and type level substitution. This
      change is partially motivated by the existential type proposal,
      which will introduce types that contain expressions and therefore
      forces us to carry around an "IdSubstEnv" even when substituting for
      types. It also reduces the amount of code because "Subst" and
      "TCvSubst" share a lot of common operations. There isn't any
      noticeable impact on performance (geo. mean for ghc/alloc is around
      0.0% but we have -94 loc and one less data type to worry abount).
      
      Currently, the "TCvSubst" data type for substitution on types is
      identical to the "Subst" data type except the former doesn't store
      "IdSubstEnv". Using "Subst" for type-level substitution means there
      will be a redundant field stored in the data type. However, in cases
      where the substitution starts from the expression, using "Subst" for
      type-level substitution saves us from having to project "Subst" into a
      "TCvSubst". This probably explains why the allocation is mostly even
      despite the redundant field.
      
      The patch deletes "TCvSubst" and moves "Subst" and its relevant
      functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst".
      Substitution on expressions is still defined in "GHC.Core.Subst" so we
      don't have to expose the definition of "Expr" in the hs-boot file that
      "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose
      codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed
      into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a
      distinct function from "isEmptySubst"; the former ignores the
      emptiness of "IdSubstEnv"). These exceptions mainly exist for
      performance reasons and will go away when "Expr" and "Type" are
      mutually recursively defined (we won't be able to take those
      shortcuts if we can't make the assumption that expressions don't
      appear in types).
      35aef18d
  9. Jun 07, 2022
  10. Apr 01, 2022
    • Jakob Brünker's avatar
      Implement \cases (Proposal 302) · 32070e6c
      Jakob Brünker authored
      This commit implements proposal 302: \cases - Multi-way lambda
      expressions.
      
      This adds a new expression heralded by \cases, which works exactly like
      \case, but can match multiple apats instead of a single pat.
      
      Updates submodule haddock to support the ITlcases token.
      
      Closes #20768
      32070e6c
  11. Mar 12, 2022
  12. Mar 05, 2022
    • sheaf's avatar
      Don't allow Float#/Double# literal patterns · 584cd5ae
      sheaf authored and Marge Bot's avatar Marge Bot committed
        This patch does the following two things:
      
          1. Fix the check in Core Lint to properly throw an error when it
             comes across Float#/Double# literal patterns. The check
             was incorrect before, because it expected the type to be
             Float/Double instead of Float#/Double#.
      
          2. Add an error in the parser when the user writes a floating-point
             literal pattern such as `case x of { 2.0## -> ... }`.
      
        Fixes #21115
      584cd5ae
  13. Mar 02, 2022
    • sheaf's avatar
      Improve out-of-order inferred type variables · f596c91a
      sheaf authored and Marge Bot's avatar Marge Bot committed
        Don't instantiate type variables for :type in
        `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting
        `r1` but not `r2` in the type
      
          forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ...
      
        This fixes #21088.
      
        This patch also changes the primop pretty-printer to ensure
        that we put all the inferred type variables first. For example,
        the type of reallyUnsafePtrEquality# is now
      
          forall {l :: Levity} {k :: Levity}
                 (a :: TYPE (BoxedRep l))
                 (b :: TYPE (BoxedRep k)).
            a -> b -> Int#
      
        This means we avoid running into issue #21088 entirely with
        the types of primops. Users can still write a type signature where
        the inferred type variables don't come first, however.
      
        This change to primops had a knock-on consequence, revealing that
        we were sometimes performing eta reduction on keepAlive#.
        This patch updates tryEtaReduce to avoid eta reducing functions
        with no binding, bringing it in line with tryEtaReducePrep,
        and thus fixing #21090.
      f596c91a
  14. Mar 01, 2022
    • sheaf's avatar
      Core Lint: collect args through floatable ticks · 7aeb6d29
      sheaf authored and Marge Bot's avatar Marge Bot committed
      We were not looking through floatable ticks when collecting arguments in
      Core Lint, which caused `checkCanEtaExpand` to fail on something like:
      
      ```haskell
      reallyUnsafePtrEquality
        = \ @a ->
            (src<loc> reallyUnsafePtrEquality#)
              @Lifted @a @Lifted @a
      ```
      
      We fix this by using `collectArgsTicks tickishFloatable` instead of
      `collectArgs`, to be consistent with the behaviour of eta expansion
      outlined in Note [Eta expansion and source notes] in GHC.Core.Opt.Arity.
      
      Fixes #21152.
      7aeb6d29
  15. Feb 26, 2022
    • sheaf's avatar
      Core Lint: ensure primops can be eta-expanded · 32d8fe3a
      sheaf authored
      This patch adds a check to Core Lint, checkCanEtaExpand,
      which ensures that primops and other wired-in functions with
      no binding such as unsafeCoerce#, oneShot, rightSection...
      can always be eta-expanded, by checking that the remaining
      argument types have a fixed RuntimeRep.
      
      Two subtleties came up:
      
        - the notion of arity in Core looks through newtypes, so we may
          need to unwrap newtypes in this check,
        - we want to avoid calling hasNoBinding on something whose unfolding
          we are in the process of linting, as this would cause a loop;
          to avoid this we add some information to the Core Lint environment
          that holds this information.
      
      Fixes #20480
      32d8fe3a
Loading