Skip to content
Snippets Groups Projects
  1. Feb 25, 2024
  2. Jun 21, 2023
  3. Mar 21, 2023
  4. Oct 26, 2022
  5. Oct 24, 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. Aug 19, 2022
  8. Feb 04, 2022
    • Ben Gamari's avatar
      compiler: Introduce and use RoughMap for instance environments · eddaa591
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      
      Here we introduce a new data structure, RoughMap, inspired by the
      previous `RoughTc` matching mechanism for checking instance matches.
      This allows [Fam]InstEnv to be implemented as a trie indexed by these
      RoughTc signatures, reducing the complexity of instance lookup and
      FamInstEnv merging (done during the family instance conflict test)
      from O(n) to O(log n).
      
      The critical performance improvement currently realised by this patch is
      in instance matching. In particular the RoughMap mechanism allows us to
      discount many potential instances which will never match for constraints
      involving type variables (see Note [Matching a RoughMap]). In realistic
      code bases matchInstEnv was accounting for 50% of typechecker time due
      to redundant work checking instances when simplifying instance contexts
      when deriving instances. With this patch the cost is significantly
      reduced.
      
      The larger constants in InstEnv creation do mean that a few small
      tests regress in allocations slightly. However, the runtime of T19703 is
      reduced by a factor of 4. Moreover, the compilation time of the Cabal
      library is slightly improved.
      
      A couple of test cases are included which demonstrate significant
      improvements in compile time with this patch.
      
      This unfortunately does not fix the testcase provided in #19703 but does
      fix #20933
      
      -------------------------
      Metric Decrease:
          T12425
      Metric Increase:
          T13719
          T9872a
          T9872d
          hard_hole_fits
      -------------------------
      
      Co-authored-by: default avatarMatthew Pickering <matthewtpickering@gmail.com>
      eddaa591
  9. Nov 20, 2021
    • sheaf's avatar
      Include "not more specific" info in overlap msg · 742d8b60
      sheaf authored and Marge Bot's avatar Marge Bot committed
        When instances overlap, we now include additional information
        about why we weren't able to select an instance: perhaps
        one instance overlapped another but was not strictly more specific,
        so we aren't able to directly choose it.
      
      Fixes #20542
      742d8b60
  10. Oct 06, 2021
    • sheaf's avatar
      Improve overlap error for polykinded constraints · a466b024
      sheaf authored and Marge Bot's avatar Marge Bot committed
      There were two problems around `mkDictErr`:
      
        1. An outdated call to `flattenTys` meant that we missed out on some
           instances. As we no longer flatten type-family applications,
           the logic is obsolete and can be removed.
      
        2. We reported "out of scope" errors in a poly-kinded situation
           because `BoxedRep` and `Lifted` were considered out of scope.
           We fix this by using `pretendNameIsInScope`.
      
      fixes #20465
      a466b024
  11. May 05, 2021
  12. Mar 28, 2021
    • Hannes Siebenhandl's avatar
      Add UnitId to Target record · 29d75863
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      In the future, we want `HscEnv` to support multiple home units
      at the same time. This means, that there will be 'Target's that do
      not belong to the current 'HomeUnit'.
      
      This is an API change without changing behaviour.
      
      Update haddock submodule to incorporate API changes.
      29d75863
  13. Mar 20, 2021
  14. Mar 10, 2021
  15. Feb 19, 2021
    • Simon Peyton Jones's avatar
      Improve handling of overloaded labels, literals, lists etc · 4196969c
      Simon Peyton Jones authored
      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
  16. Feb 16, 2021
    • Ryan Scott's avatar
      Parse symbolic names in ANN type correctly with otycon · a04179e7
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      This adds a new `otycon` production to the parser that allows for type
      constructor names that are either alphanumeric (`tycon`) or symbolic
      (`tyconsym`), where the latter must be parenthesized appropriately.
      `otycon` is much like the existing `oqtycon` production, except that it does
      not permit qualified names. The parser now uses `otycon` to parse type
      constructor names in `ANN type` declarations, which fixes #19374.
      
      To make sure that all of this works, I added three test cases:
      
      * `should_compile/T19374a`: the original test case from #19374
      * `should_fail/T19374b`: a test that makes sure that an `ANN` with a qualified
        name fails to parse
      * `should_fail/T19374c`: a test that makes sure that an `ANN type` with a
        qualified name fails to parse
      a04179e7
  17. Jan 27, 2021
    • Ben Gamari's avatar
      Add instances for GHC.Tuple.Solo · 5d6009a8
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      The `Applicative` instance is the most important one (for
      array/vector/sequence indexing purposes), but it deserves
      all the usual ones.
      
      T12545 does silly 1% wibbles both ways, it seems, maybe depending
      on architecture.
      
      Metric Increase:
          T12545
      
      Metric Decrease:
          T12545
      5d6009a8
  18. Jun 17, 2020
    • Sylvain Henry's avatar
      Update testsuite · f817d816
      Sylvain Henry authored
      * support detection of slow ghc-bignum backend (to replace the detection
        of integer-simple use). There are still some test cases that the
        native backend doesn't handle efficiently enough.
      
      * remove tests for GMP only functions that have been removed from
        ghc-bignum
      
      * fix test results showing dependent packages (e.g. integer-gmp) or
        showing suggested instances
      
      * fix test using Integer/Natural API or showing internal names
      f817d816
  19. Jun 05, 2020
    • Simon Peyton Jones's avatar
      Simple subsumption · 2b792fac
      Simon Peyton Jones authored
      This patch simplifies GHC to use simple subsumption.
        Ticket #17775
      
      Implements GHC proposal #287
         https://github.com/ghc-proposals/ghc-proposals/blob/master/
         proposals/0287-simplify-subsumption.rst
      
      All the motivation is described there; I will not repeat it here.
      The implementation payload:
       * tcSubType and friends become noticably simpler, because it no
         longer uses eta-expansion when checking subsumption.
       * No deeplyInstantiate or deeplySkolemise
      
      That in turn means that some tests fail, by design; they can all
      be fixed by eta expansion.  There is a list of such changes below.
      
      Implementing the patch led me into a variety of sticky corners, so
      the patch includes several othe changes, some quite significant:
      
      * I made String wired-in, so that
          "foo" :: String   rather than
          "foo" :: [Char]
        This improves error messages, and fixes #15679
      
      * The pattern match checker relies on knowing about in-scope equality
        constraints, andd adds them to the desugarer's environment using
        addTyCsDs.  But the co_fn in a FunBind was missed, and for some reason
        simple-subsumption ends up with dictionaries there. So I added a
        call to addTyCsDs.  This is really part of #18049.
      
      * I moved the ic_telescope field out of Implication and into
        ForAllSkol instead.  This is a nice win; just expresses the code
        much better.
      
      * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader.
        We called checkDataKindSig inside tc_kind_sig, /before/
        solveEqualities and zonking.  Obviously wrong, easily fixed.
      
      * solveLocalEqualitiesX: there was a whole mess in here, around
        failing fast enough.  I discovered a bad latent bug where we
        could successfully kind-check a type signature, and use it,
        but have unsolved constraints that could fill in coercion
        holes in that signature --  aargh.
      
        It's all explained in Note [Failure in local type signatures]
        in GHC.Tc.Solver. Much better now.
      
      * I fixed a serious bug in anonymous type holes. IN
          f :: Int -> (forall a. a -> _) -> Int
        that "_" should be a unification variable at the /outer/
        level; it cannot be instantiated to 'a'.  This was plain
        wrong.  New fields mode_lvl and mode_holes in TcTyMode,
        and auxiliary data type GHC.Tc.Gen.HsType.HoleMode.
      
        This fixes #16292, but makes no progress towards the more
        ambitious #16082
      
      * I got sucked into an enormous refactoring of the reporting of
        equality errors in GHC.Tc.Errors, especially in
            mkEqErr1
            mkTyVarEqErr
            misMatchMsg
            misMatchMsgOrCND
        In particular, the very tricky mkExpectedActualMsg function
        is gone.
      
        It took me a full day.  But the result is far easier to understand.
        (Still not easy!)  This led to various minor improvements in error
        output, and an enormous number of test-case error wibbles.
      
        One particular point: for occurs-check errors I now just say
           Can't match 'a' against '[a]'
        rather than using the intimidating language of "occurs check".
      
      * Pretty-printing AbsBinds
      
      Tests review
      
      * Eta expansions
         T11305: one eta expansion
         T12082: one eta expansion (undefined)
         T13585a: one eta expansion
         T3102:  one eta expansion
         T3692:  two eta expansions (tricky)
         T2239:  two eta expansions
         T16473: one eta
         determ004: two eta expansions (undefined)
         annfail06: two eta (undefined)
         T17923: four eta expansions (a strange program indeed!)
         tcrun035: one eta expansion
      
      * Ambiguity check at higher rank.  Now that we have simple
        subsumption, a type like
           f :: (forall a. Eq a => Int) -> Int
        is no longer ambiguous, because we could write
           g :: (forall a. Eq a => Int) -> Int
           g = f
        and it'd typecheck just fine.  But f's type is a bit
        suspicious, and we might want to consider making the
        ambiguity check do a check on each sub-term.  Meanwhile,
        these tests are accepted, whereas they were previously
        rejected as ambiguous:
           T7220a
           T15438
           T10503
           T9222
      
      * Some more interesting error message wibbles
         T13381: Fine: one error (Int ~ Exp Int)
                 rather than two (Int ~ Exp Int, Exp Int ~ Int)
         T9834:  Small change in error (improvement)
         T10619: Improved
         T2414:  Small change, due to order of unification, fine
         T2534:  A very simple case in which a change of unification order
                 means we get tow unsolved constraints instead of one
         tc211: bizarre impredicative tests; just accept this for now
      
      Updates Cabal and haddock submodules.
      
      Metric Increase:
        T12150
        T12234
        T5837
        haddock.base
      Metric Decrease:
        haddock.compiler
        haddock.Cabal
        haddock.base
      
      Merge note: This appears to break the
      `UnliftedNewtypesDifficultUnification` test. It has been marked as
      broken in the interest of merging.
      
      (cherry picked from commit 66b7b195)
      2b792fac
  20. Apr 26, 2020
  21. Apr 23, 2020
    • Simon Peyton Jones's avatar
      Do eager instantation in terms · ffde2348
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch implements eager instantiation, a small but critical change
      to the type inference engine, #17173.  The main change is this:
      
        When inferring types, always return an instantiated type
        (for now, deeply instantiated; in future shallowly instantiated)
      
      There is more discussion in
      https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html
      
      There is quite a bit of refactoring in this patch:
      
      * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk
        has entirely gone.  So tcInferInst and tcInferNoInst have collapsed
        into tcInfer.
      
      * Type inference of applications, via tcInferApp and
        tcInferAppHead, are substantially refactored, preparing
        the way for Quick Look impredicativity.
      
      * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs
        are beatifully dual.  We can see the zipper!
      
      * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return
        a wrapper
      
      * In HsExpr, HsTypeApp now contains the the actual type argument,
        and is used in desugaring, rather than putting it in a mysterious
        wrapper.
      
      * I struggled a bit with good error reporting in
        Unify.matchActualFunTysPart. It's a little bit simpler than before,
        but still not great.
      
      Some smaller things
      
      * Rename tcPolyExpr --> tcCheckExpr
               tcMonoExpr --> tcLExpr
      * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat
      
      Metric Decrease:
          T9961
      
      Reduction of 1.6% in comiler allocation on T9961, I think.
      ffde2348
  22. Mar 29, 2020
  23. Feb 22, 2020
  24. Feb 08, 2020
  25. Dec 04, 2019
    • Ben Gamari's avatar
      Simplify uniqAway · 78b67ad0
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      This does two things:
      
       * Eliminate all uses of Unique.deriveUnique, which was quite easy to
         mis-use and extremely subtle.
      
       * Rename the previous "derived unique" notion to "local unique". This
         is possible because the only places where `uniqAway` can be safely
         used are those where local uniqueness (with respect to some
         InScopeSet) is sufficient.
      
       * Rework the implementation of VarEnv.uniqAway, as discussed in #17462.
         This should make the operation significantly more efficient than its
         previous iterative implementation..
      
      Metric Decrease:
          T9872c
          T12227
          T9233
          T14683
          T5030
          T12545
          hie002
      
      Metric Increase:
          T9961
      78b67ad0
  26. Mar 15, 2019
  27. Jan 30, 2019
  28. Aug 07, 2018
    • Herbert Valerio Riedel's avatar
      Turn on MonadFail desugaring by default · aab8656b
      Herbert Valerio Riedel authored and Ben Gamari's avatar Ben Gamari committed
      Summary:
      This contains two commits:
      
      ----
      
      Make GHC's code-base compatible w/ `MonadFail`
      
      There were a couple of use-sites which implicitly used pattern-matches
      in `do`-notation even though the underlying `Monad` didn't explicitly
      support `fail`
      
      This refactoring turns those use-sites into explicit case
      discrimations and adds an `MonadFail` instance for `UniqSM`
      (`UniqSM` was the worst offender so this has been postponed for a
      follow-up refactoring)
      
      ---
      
      Turn on MonadFail desugaring by default
      
      This finally implements the phase scheduled for GHC 8.6 according to
      
      https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail#Transitionalstrategy
      
      This also preserves some tests that assumed MonadFail desugaring to be
      active; all ghc boot libs were already made compatible with this
      `MonadFail` long ago, so no changes were needed there.
      
      Test Plan: Locally performed ./validate --fast
      
      Reviewers: bgamari, simonmar, jrtc27, RyanGlScott
      
      Reviewed By: bgamari
      
      Subscribers: bgamari, RyanGlScott, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D5028
      aab8656b
  29. Jun 20, 2018
  30. May 27, 2018
  31. Sep 13, 2017
  32. Sep 05, 2017
    • Ben Gamari's avatar
      testsuite: Add test for #14129 · b996e12d
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      It's not impossible that this will also get caught by another test given
      a suitably configured compiler, but this is minimal enough that it seems
      worth including.
      
      Test Plan: Validate with `DYNAMIC_GHC_PROGRAMS=NO`
      
      Reviewers: austin
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14129
      
      Differential Revision: https://phabricator.haskell.org/D3924
      b996e12d
  33. Sep 04, 2017
  34. Jul 11, 2017
    • Douglas Wilson's avatar
      Add testcase for T13818 · 6cff2cad
      Douglas Wilson authored and Ben Gamari's avatar Ben Gamari committed
      Annotations currently fail to type check if they annotation cannot
      be loaded into ghci, such as when built with -fno-code.
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #13818
      
      Differential Revision: https://phabricator.haskell.org/D3701
      6cff2cad
  35. Feb 26, 2017
    • rwbarton's avatar
      tests: remove extra_files.py (#12223) · 3415bcaa
      rwbarton authored and Ben Gamari's avatar Ben Gamari committed
      The script I used is included as testsuite/driver/kill_extra_files.py,
      though at this point it is for mostly historical interest.
      
      Some of the tests in libraries/hpc relied on extra_files.py, so this
      commit includes an update to that submodule.
      
      One test in libraries/process also relies on extra_files.py, but we
      cannot update that submodule so easily, so for now we special-case it
      in the test driver.
      3415bcaa
  36. Feb 23, 2017
  37. Feb 02, 2017
Loading