Skip to content
Snippets Groups Projects
  1. Jul 03, 2023
  2. Jun 26, 2023
    • Sylvain Henry's avatar
      JS: support levity-polymorphic datatypes (#22360,#22291) · 8d6574bc
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      - thread knowledge about levity into PrimRep instead of panicking
      - JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.)
      
      Doing this also fixes #22291 (test added).
      
      There is a small performance hit (~1% more allocations).
      
      Metric Increase:
          T18698a
          T18698b
      8d6574bc
  3. Jun 13, 2023
  4. Nov 29, 2022
  5. Nov 25, 2022
    • Vladislav Zavialov's avatar
      Print unticked promoted data constructors (#20531) · 13d627bb
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      
      Before this patch, GHC unconditionally printed ticks before promoted
      data constructors:
      
      	ghci> type T = True  -- unticked (user-written)
      	ghci> :kind! T
      	T :: Bool
      	= 'True              -- ticked (compiler output)
      
      After this patch, GHC prints ticks only when necessary:
      
      	ghci> type F = False    -- unticked (user-written)
      	ghci> :kind! F
      	F :: Bool
      	= False                 -- unticked (compiler output)
      
      	ghci> data False        -- introduce ambiguity
      	ghci> :kind! F
      	F :: Bool
      	= 'False                -- ticked by necessity (compiler output)
      
      The old behavior can be enabled by -fprint-redundant-promotion-ticks.
      
      Summary of changes:
      * Rename PrintUnqualified to NamePprCtx
      * Add QueryPromotionTick to it
      * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick)
      * Introduce -fprint-redundant-promotion-ticks
      
      Co-authored-by: default avatarArtyom Kuznetsov <hi@wzrd.ht>
      13d627bb
  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. Mar 14, 2022
    • sheaf's avatar
      Fix isLiftedType_maybe and handle fallout · 8eadea67
      sheaf authored and Marge Bot's avatar Marge Bot committed
      As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in
      many situations where it should return `Nothing`, because it didn't
      take into account type families or type variables.
      
      In this patch, we fix this issue. We rename `isLiftedType_maybe` to
      `typeLevity_maybe`, which now returns a `Levity` instead of a boolean.
      We now return `Nothing` for types with kinds of the form
      `TYPE (F a1 ... an)` for a type family `F`, as well as
      `TYPE (BoxedRep l)` where `l` is a type variable.
      
      This fix caused several other problems, as other parts of the compiler
      were relying on `isLiftedType_maybe` returning a `Just` value, and were
      now panicking after the above fix. There were two main situations in
      which panics occurred:
      
        1. Issues involving the let/app invariant. To uphold that invariant,
           we need to know whether something is lifted or not. If we get an
           answer of `Nothing` from `isLiftedType_maybe`, then we don't know
           what to do. As this invariant isn't particularly invariant, we
           can change the affected functions to not panic, e.g. by behaving
           the same in the `Just False` case and in the `Nothing` case
           (meaning: no observable change in behaviour compared to before).
      
        2. Typechecking of data (/newtype) constructor patterns. Some programs
           involving patterns with unknown representations were accepted, such
           as T20363. Now that we are stricter, this caused further issues,
           culminating in Core Lint errors. However, the behaviour was
           incorrect the whole time; the incorrectness only being revealed by
           this change, not triggered by it.
      
           This patch fixes this by overhauling where the representation
           polymorphism involving pattern matching are done. Instead of doing
           it in `tcMatches`, we instead ensure that the `matchExpected`
           functions such as `matchExpectedFunTys`, `matchActualFunTySigma`,
           `matchActualFunTysRho` allow return argument pattern types which
           have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]).
           This ensures that the pattern matching code only ever handles types
           with a known runtime representation. One exception was that
           patterns with an unknown representation type could sneak in via
           `tcConPat`, which points to a missing representation-polymorphism
           check, which this patch now adds.
      
           This means that we now reject the program in #20363, at least until
           we implement PHASE 2 of FixedRuntimeRep (allowing type families in
           RuntimeRep positions). The aforementioned refactoring, in which
           checks have been moved to `matchExpected` functions, is a first
           step in implementing PHASE 2 for patterns.
      
      Fixes #20837
      8eadea67
  8. Oct 26, 2021
    • sheaf's avatar
      Don't default type variables in type families · 9cc6c193
      sheaf authored and Marge Bot's avatar Marge Bot committed
        This patch removes the following defaulting of type variables
        in type and data families:
      
          - type variables of kind RuntimeRep defaulting to LiftedRep
          - type variables of kind Levity defaulting to Lifted
          - type variables of kind Multiplicity defaulting to Many
      
        It does this by passing "defaulting options" to the `defaultTyVars`
        function; when calling from `tcTyFamInstEqnGuts` or
        `tcDataFamInstHeader` we pass options that avoid defaulting.
      
        This avoids wildcards being defaulted, which caused type families
        to unexpectedly fail to reduce.
      
        Note that kind defaulting, applicable only with -XNoPolyKinds,
        is not changed by this patch.
      
        Fixes #17536
      
      -------------------------
      Metric Increase:
          T12227
      -------------------------
      9cc6c193
  9. Mar 14, 2021
    • Sebastian Graf's avatar
      Implement the UnliftedDatatypes extension · b73c9c5f
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      GHC Proposal: 0265-unlifted-datatypes.rst
      Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/265
      Issues: ghc/ghc#19523
      Implementation Details: Note [Implementation of UnliftedDatatypes]
      
      This patch introduces the `UnliftedDatatypes` extension. When this extension is
      enabled, GHC relaxes the restrictions around what result kinds are allowed in
      data declarations. This allows data types for which an unlifted or
      levity-polymorphic result kind is inferred.
      
      The most significant changes are in `GHC.Tc.TyCl`, where
      `Note [Implementation of UnliftedDatatypes]` describes the details of the
      implementation.
      
      Fixes #19523.
      b73c9c5f
Loading