1. 06 May, 2022 1 commit
    • Matthew Pickering's avatar
      template-haskell: Fix representation of OPAQUE pragmas · 0415449a
      Matthew Pickering authored and  Marge Bot's avatar Marge Bot committed
      There is a mis-match between the TH representation of OPAQUE pragmas and
      GHC's internal representation due to how OPAQUE pragmas disallow phase
      annotations. It seemed most in keeping to just fix the wired in name
      issue by adding a special case to the desugaring of INLINE pragmas
      rather than making TH/GHC agree with how the representation should look.
      
      Fixes #21463
      0415449a
  2. 01 Apr, 2022 2 commits
    • 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
    • sheaf's avatar
      Keep track of promotion ticks in HsOpTy · d85c7dcb
      sheaf authored and Matthew Pickering's avatar Matthew Pickering committed
      This patch adds a PromotionFlag field to HsOpTy, which is used
      in pretty-printing and when determining whether to emit warnings
      with -fwarn-unticked-promoted-constructors.
      
      This allows us to correctly report tick-related warnings for things
      like:
      
        type A = Int : '[]
        type B = [Int, Bool]
      
      Updates haddock submodule
      
      Fixes #19984
      d85c7dcb
  3. 25 Mar, 2022 1 commit
  4. 18 Mar, 2022 4 commits
    • romes's avatar
      TTG: TH brackets finishing touches · ac3b2e7d
      romes authored and  Marge Bot's avatar Marge Bot committed
      Rewrite the critical notes and fix outdated ones,
      
      use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the
      bracket being typed or untyped,
      
      remove unused `EpAnn` from `Hs*Bracket GhcRn`,
      
      zonkExpr factor out common brackets code,
      
      ppr_expr factor out common brackets code,
      
      and fix tests,
      
      to finish MR !4782.
      
      -------------------------
      Metric Decrease:
          hard_hole_fits
      -------------------------
      ac3b2e7d
    • romes's avatar
      TTG: Refactor bracket for desugaring during tc · 4a2567f5
      romes authored and  Marge Bot's avatar Marge Bot committed
      When desugaring a bracket we want to desugar /renamed/ rather than
      /typechecked/ code; So in (HsExpr GhcTc) tree, we must
      have a (HsExpr GhcRn) for the quotation itself.
      
      This commit reworks the TTG refactor on typed and untyped brackets by
      storing the /renamed/ code in the bracket field extension rather than in
      the constructor extension in `HsQuote` (previously called
      `HsUntypedBracket`)
      
      See Note [The life cycle of a TH quotation] and !4782
      4a2567f5
    • romes's avatar
      Separate constructors for typed and untyped brackets · 310890a5
      romes authored and  Marge Bot's avatar Marge Bot committed
      Split HsBracket into HsTypedBracket and HsUntypedBracket.
      
      Unfortunately, we still cannot get rid of
      
          instance XXTypedBracket GhcTc = HsTypedBracket GhcRn
      
      despite no longer requiring it for typechecking, but rather because the
      TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote)
      310890a5
    • romes's avatar
      TTG: Refactor HsBracket · 8561c1af
      romes authored and  Marge Bot's avatar Marge Bot committed
      8561c1af
  5. 16 Mar, 2022 1 commit
    • Zubin's avatar
      TH: allow negative patterns in quotes (#20711) · a33d1045
      Zubin authored and  Marge Bot's avatar Marge Bot committed
      We still don't allow negative overloaded patterns. Earler all negative patterns
      were treated as negative overloaded patterns. Now, we expliclty check the
      extension field to see if the pattern is actually a negative overloaded pattern
      a33d1045
  6. 14 Mar, 2022 1 commit
    • romes's avatar
      TTG Pull AbsBinds and ABExport out of the main AST · 135888dd
      romes authored and  Marge Bot's avatar Marge Bot committed
      AbsBinds and ABExport both depended on the typechecker, and were thus
      removed from the main AST Expr.
      
      CollectPass now has a new function `collectXXHsBindsLR` used for the new
      HsBinds extension point
      
      Bumped haddock submodule to work with AST changes.
      
      The removed Notes from Language.Haskell.Syntax.Binds were duplicated
      (and not referenced) and the copies in GHC.Hs.Binds are kept (and
      referenced there). (See #19252)
      135888dd
  7. 23 Feb, 2022 1 commit
    • Richard Eisenberg's avatar
      Kill derived constraints · a599abba
      Richard Eisenberg authored and  Marge Bot's avatar Marge Bot committed
      Co-authored by: Sam Derbyshire
      
      Previously, GHC had three flavours of constraint:
      Wanted, Given, and Derived. This removes Derived constraints.
      
      Though serving a number of purposes, the most important role
      of Derived constraints was to enable better error messages.
      This job has been taken over by the new RewriterSets, as explained
      in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint.
      
      Other knock-on effects:
       - Various new Notes as I learned about under-described bits of GHC
      
       - A reshuffling around the AST for implicit-parameter bindings,
         with better integration with TTG.
      
       - Various improvements around fundeps. These were caused by the
         fact that, previously, fundep constraints were all Derived,
         and Derived constraints would get dropped. Thus, an unsolved
         Derived didn't stop compilation. Without Derived, this is no
         longer possible, and so we have to be considerably more careful
         around fundeps.
      
       - A nice little refactoring in GHC.Tc.Errors to center the work
         on a new datatype called ErrorItem. Constraints are converted
         into ErrorItems at the start of processing, and this allows for
         a little preprocessing before the main classification.
      
       - This commit also cleans up the behavior in generalisation around
         functional dependencies. Now, if a variable is determined by
         functional dependencies, it will not be quantified. This change
         is user facing, but it should trim down GHC's strange behavior
         around fundeps.
      
       - Previously, reportWanteds did quite a bit of work, even on an empty
         WantedConstraints. This commit adds a fast path.
      
       - Now, GHC will unconditionally re-simplify constraints during
         quantification. See Note [Unconditionally resimplify constraints when
         quantifying], in GHC.Tc.Solver.
      
      Close #18398.
      Close #18406.
      Solve the fundep-related non-confluence in #18851.
      Close #19131.
      Close #19137.
      Close #20922.
      Close #20668.
      Close #19665.
      
      -------------------------
      Metric Decrease:
          LargeRecord
          T9872b
          T9872b_defer
          T9872d
          TcPlugin_RewritePerf
      -------------------------
      a599abba
  8. 01 Feb, 2022 1 commit
  9. 25 Nov, 2021 1 commit
    • Krzysztof Gogolewski's avatar
      Misc cleanup · e33412d0
      Krzysztof Gogolewski authored and  Marge Bot's avatar Marge Bot committed
      * Remove `getTag_RDR` (unused), `tidyKind` and `tidyOpenKind`
        (already available as `tidyType` and `tidyOpenType`)
      
      * Remove Note [Explicit Case Statement for Specificity].
        Since 0a709dd9 we require GHC 8.10 for bootstrapping.
      
      * Change the warning to `cmpAltCon` to a panic.
        This shouldn't happen.  If it ever does, the code was wrong anyway:
        it shouldn't always return `LT`, but rather `LT` in one case
        and `GT` in the other case.
      
      * Rename `verifyLinearConstructors` to `verifyLinearFields`
      
      * Fix `Note [Local record selectors]` which was not referenced
      
      * Remove vestiges of `type +v`
      
      * Minor fixes to StaticPointers documentation, part of #15603
      e33412d0
  10. 20 Nov, 2021 1 commit
    • Zubin's avatar
      Use 'NonEmpty' for the fields in an 'HsProjection' (#20389) · bc7e9f03
      Zubin authored and Zubin's avatar Zubin committed
      T12545 is very inconsistently affected by this change for some reason.
      There is a decrease in allocations on most configurations, but
      an increase on validate-x86_64-linux-deb9-unreg-hadrian. Accepting it
      as it seems unrelated to this patch.
      
      Metric Decrease:
          T12545
      Metric Increase:
          T12545
      bc7e9f03
  11. 02 Nov, 2021 2 commits
  12. 30 Sep, 2021 1 commit
  13. 11 Sep, 2021 1 commit
    • Sylvain Henry's avatar
      Canonicalize bignum literals · 089de88e
      Sylvain Henry authored and  Marge Bot's avatar Marge Bot committed
      Before this patch Integer and Natural literals were desugared into "real"
      Core in Core prep. Now we desugar them directly into their final ConApp
      form in HsToCore. We only keep the double representation for BigNat#
      (literals larger than a machine Word/Int) which are still desugared in
      Core prep.
      
      Using the final form directly allows case-of-known-constructor to fire
      for bignum literals, fixing #20245.
      
      Slight increase (+2.3) in T4801 which is a pathological case with
      Integer literals.
      
      Metric Increase:
          T4801
          T11545
      089de88e
  14. 11 Aug, 2021 1 commit
    • Alina Banerjee's avatar
      Modify InlineSpec data constructor (helps fix #18138) · 100ffe75
      Alina Banerjee authored and  Marge Bot's avatar Marge Bot committed
      The inl_inline field of the InlinePragma record is modified to store pragma
      source text by adding a data constructor of type SourceText. This can help in
      tracking the actual text of pragma names.
      
      Add/modify functions, modify type instance for InlineSpec type
      
      Modify parser, lexer to handle InlineSpec constructors containing SourceText
      
      Modify functions with InlineSpec type
      
      Extract pragma source from InlineSpec for SpecSig, InlineSig types
      
      Modify cvtInline function to add SourceText to InlineSpec type
      
      Extract name for InlineSig, SpecSig from pragma, SpectInstSig from source (fixes #18138)
      
      Extract pragma name for SpecPrag pragma, SpecSig signature
      
      Add Haddock annotation for inlinePragmaName function
      
      Add Haddock annotations for using helper functions in hsSigDoc
      
      Remove redundant ppr in pragma name for SpecSig, InlineSig; update comment
      
      Rename test to T18138 for misplaced SPECIALIZE pragma testcase
      100ffe75
  15. 03 Aug, 2021 1 commit
  16. 02 Aug, 2021 1 commit
  17. 21 Jul, 2021 1 commit
  18. 29 Jun, 2021 1 commit
  19. 17 Jun, 2021 1 commit
  20. 03 Jun, 2021 1 commit
    • Alfredo Di Napoli's avatar
      Port HsToCore messages to new infrastructure · d5b89ed4
      Alfredo Di Napoli authored and  Marge Bot's avatar Marge Bot committed
      This commit converts a bunch of HsToCore (Ds) messages to use the new
      GHC's diagnostic message infrastructure. In particular the DsMessage
      type has been expanded with a lot of type constructors, each
      encapsulating a particular error and warning emitted during desugaring.
      
      Due to the fact that levity polymorphism checking can happen both at the
      Ds and at the TcRn level, a new `TcLevityCheckDsMessage` constructor has
      been added to the `TcRnMessage` type.
      d5b89ed4
  21. 23 May, 2021 1 commit
  22. 22 May, 2021 1 commit
    • Shayne Fletcher's avatar
      Change representation of field selector occurences · 0b1eed74
      Shayne Fletcher authored
      - Change the names of the fields in in `data FieldOcc`
      - Renames `HsRecFld` to `HsRecSel`
      - Replace `AmbiguousFieldOcc p` in `HsRecSel` with `FieldOcc p`
      - Contains a haddock submodule update
      
      The primary motivation of this change is to remove
      `AmbiguousFieldOcc`. This is one of a suite of changes improving how
      record syntax (most notably record update syntax) is represented in
      the AST.
      0b1eed74
  23. 20 May, 2021 1 commit
  24. 13 May, 2021 3 commits
    • Sylvain Henry's avatar
      Remove useless {-# LANGUAGE CPP #-} pragmas · 67a5a91e
      Sylvain Henry authored and  Marge Bot's avatar Marge Bot committed
      67a5a91e
    • Sylvain Henry's avatar
      Fully remove HsVersions.h · 0ef11907
      Sylvain Henry authored and  Marge Bot's avatar Marge Bot committed
      Replace uses of WARN macro with calls to:
      
        warnPprTrace :: Bool -> SDoc -> a -> a
      
      Remove the now unused HsVersions.h
      
      Bump haddock submodule
      0ef11907
    • Sylvain Henry's avatar
      Replace CPP assertions with Haskell functions · bfabf94f
      Sylvain Henry authored and  Marge Bot's avatar Marge Bot committed
      There is no reason to use CPP. __LINE__ and __FILE__ macros are now
      better replaced with GHC's CallStack. As a bonus, assert error messages
      now contain more information (function name, column).
      
      Here is the mapping table (HasCallStack omitted):
      
        * ASSERT:   assert     :: Bool -> a -> a
        * MASSERT:  massert    :: Bool -> m ()
        * ASSERTM:  assertM    :: m Bool -> m ()
        * ASSERT2:  assertPpr  :: Bool -> SDoc -> a -> a
        * MASSERT2: massertPpr :: Bool -> SDoc -> m ()
        * ASSERTM2: assertPprM :: m Bool -> SDoc -> m ()
      bfabf94f
  25. 20 Mar, 2021 1 commit
  26. 07 Mar, 2021 1 commit
  27. 01 Mar, 2021 1 commit
  28. 19 Feb, 2021 1 commit
    • Simon Peyton Jones's avatar
      Improve handling of overloaded labels, literals, lists etc · 4196969c
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      When implementing Quick Look I'd failed to remember that overloaded
      labels, like #foo, should be treated as a "head", so that they can be
      instantiated with Visible Type Application. This caused #19154.
      
      A very similar ticket covers overloaded literals: #19167.
      
      This patch fixes both problems, but (annoyingly, albeit temporarily)
      in two different ways.
      
      Overloaded labels
      
      I dealt with overloaded labels by buying fully into the
      Rebindable Syntax approach described in GHC.Hs.Expr
      Note [Rebindable syntax and HsExpansion].
      
      There is a good overview in GHC.Rename.Expr
      Note [Handling overloaded and rebindable constructs].
      That module contains much of the payload for this patch.
      
      Specifically:
      
      * Overloaded labels are expanded in the renamer, fixing #19154.
        See Note [Overloaded labels] in GHC.Rename.Expr.
      
      * Left and right sections used to have special code paths in the
        typechecker and desugarer.  Now we just expand them in the
        renamer. This is harder than it sounds.  See GHC.Rename.Expr
        Note [Left and right sections].
      
      * Infix operator applications are expanded in the typechecker,
        specifically in GHC.Tc.Gen.App.splitHsApps.  See
        Note [Desugar OpApp in the typechecker] in that module
      
      * ExplicitLists are expanded in the renamer, when (and only when)
        OverloadedLists is on.
      
      * HsIf is expanded in the renamer when (and only when) RebindableSyntax
        is on.  Reason: the coverage checker treats HsIf specially.  Maybe
        we could instead expand it unconditionally, and fix up the coverage
        checker, but I did not attempt that.
      
      Overloaded literals
      
      Overloaded literals, like numbers (3, 4.2) and strings with
      OverloadedStrings, were not working correctly with explicit type
      applications (see #19167).  Ideally I'd also expand them in the
      renamer, like the stuff above, but I drew back on that because they
      can occur in HsPat as well, and I did not want to to do the HsExpanded
      thing for patterns.
      
      But they *can* now be the "head" of an application in the typechecker,
      and hence something like ("foo" @T) works now.  See
      GHC.Tc.Gen.Head.tcInferOverLit.  It's also done a bit more elegantly,
      rather than by constructing a new HsExpr and re-invoking the
      typechecker. There is some refactoring around tcShortCutLit.
      
      Ultimately there is more to do here, following the Rebindable Syntax
      story.
      
      There are a lot of knock-on effects:
      
      * HsOverLabel and ExplicitList no longer need funny (Maybe SyntaxExpr)
        fields to support rebindable syntax -- good!
      
      * HsOverLabel, OpApp, SectionL, SectionR all become impossible in the
        output of the typecheker, GhcTc; so we set their extension fields to
        Void. See GHC.Hs.Expr Note [Constructor cannot occur]
      
      * Template Haskell quotes for HsExpanded is a bit tricky.  See
        Note [Quotation and rebindable syntax] in GHC.HsToCore.Quote.
      
      * In GHC.HsToCore.Match.viewLExprEq, which groups equal HsExprs for the
        purpose of pattern-match overlap checking, I found that dictionary
        evidence for the same type could have two different names.  Easily
        fixed by comparing types not names.
      
      * I did quite a bit of annoying fiddling around in GHC.Tc.Gen.Head and
        GHC.Tc.Gen.App to get error message locations and contexts right,
        esp in splitHsApps, and the HsExprArg type.  Tiresome and not very
        illuminating.  But at least the tricky, higher order, Rebuilder
        function is gone.
      
      * Some refactoring in GHC.Tc.Utils.Monad around contexts and locations
        for rebindable syntax.
      
      * Incidentally fixes #19346, because we now print renamed, rather than
        typechecked, syntax in error mesages about applications.
      
      The commit removes the vestigial module GHC.Builtin.RebindableNames,
      and thus triggers a 2.4% metric decrease for test MultiLayerModules
      (#19293).
      
      Metric Decrease:
          MultiLayerModules
          T12545
      4196969c
  29. 17 Feb, 2021 1 commit
    • Ryan Scott's avatar
      Fix #19377 by using lookupLOcc when desugaring TH-quoted ANNs · dbf8f6fe
      Ryan Scott authored and  Marge Bot's avatar Marge Bot committed
      Previously, the desugarer was looking up names referenced in TH-quoted `ANN`s
      by using `globalVar`, which would allocate a fresh TH `Name`. In effect, this
      would prevent quoted `ANN`s from ever referencing the correct identifier
      `Name`, leading to #19377. The fix is simple: instead of `globalVar`, use
      `lookupLOcc`, which properly looks up the name of the in-scope identifier.
      
      Fixes #19377.
      dbf8f6fe
  30. 06 Feb, 2021 1 commit
    • Daniel Rogozin's avatar
      The Char kind (#11342) · 7f3524ef
      Daniel Rogozin authored and  Marge Bot's avatar Marge Bot committed
      
      Co-authored-by: Rinat Striungis's avatarRinat Stryungis <rinat.stryungis@serokell.io>
      
      Implement GHC Proposal #387
      
      * Parse char literals 'x' at the type level
      * New built-in type families CmpChar, ConsSymbol, UnconsSymbol
      * New KnownChar class (cf. KnownSymbol and KnownNat)
      * New SomeChar type (cf. SomeSymbol and SomeNat)
      * CharTyLit support in template-haskell
      
      Updated submodules: binary, haddock.
      
      Metric Decrease:
          T5205
          haddock.base
      
      Metric Increase:
          Naperian
          T13035
      7f3524ef
  31. 30 Jan, 2021 1 commit
    • Simon Peyton Jones's avatar
      Make PatSyn immutable · 3b823533
      Simon Peyton Jones authored and  Marge Bot's avatar Marge Bot committed
      Provoked by #19074, this patch makes GHC.Core.PatSyn.PatSyn
      immutable, by recording only the *Name* of the matcher and
      builder rather than (as currently) the *Id*.
      
      See Note [Keep Ids out of PatSyn] in GHC.Core.PatSyn.
      
      Updates haddock submodule.
      3b823533
  32. 29 Jan, 2021 1 commit
  33. 22 Jan, 2021 1 commit