1. 01 Feb, 2018 3 commits
    • Simon Peyton Jones's avatar
      Look inside implications in simplifyRule · d3573e4a
      Simon Peyton Jones authored
      Trac #14732 was a perpelexing bug in which -fdefer-typed-holes
      caused a mysterious type error in a RULE.  This turned out to
      be because we are more aggressive about creating implications
      when deferring (see TcUnify.implicationNeeded), and the rule
      mechanism hadn't caught up.
      
      This fixes it.
      
      (cherry picked from commit e9ae0cae)
      d3573e4a
    • Simon Peyton Jones's avatar
      Prioritise equalities when solving, incl deriveds · 77cdf60c
      Simon Peyton Jones authored
      We already prioritise equalities when solving, but
      Trac #14723 showed that we were not doing so consistently
      enough, and as a result the type checker could go into a loop.
      Yikes.
      
      See Note [Prioritise equalities] in TcSMonad.
      
      Fixng this bug changed the solve order enough to demonstrate
      a problem with fundeps: Trac #14745.
      
      (cherry picked from commit efba0546)
      77cdf60c
    • Simon Peyton Jones's avatar
      Move zonkWC to the right place in simplfyInfer · e6c14744
      Simon Peyton Jones authored
      runTcSWithEvBinds does some unification, so the zonkWC
      must be after, not before!  Yikes.  An outright bug.
      
      This fixes Trac #14715.
      
      (cherry picked from commit e7c3878d)
      e6c14744
  2. 29 Jan, 2018 1 commit
    • Ryan Scott's avatar
      Fix #14719 by using the setting the right SrcSpan · c60c6590
      Ryan Scott authored
      Currently, error messages that germane to GADT constructors
      put the source span at only the first character in the constructor,
      leading to insufficient caret diagnostics. This can be easily fixed
      by using a source span that spans the entire constructor, instead of
      just the first character.
      
      Test Plan: make test TEST=T14719
      
      Reviewers: alanz, bgamari, simonpj
      
      Reviewed By: alanz, simonpj
      
      Subscribers: simonpj, goldfire, rwbarton, thomie, carter
      
      GHC Trac Issues: #14719
      
      Differential Revision: https://phabricator.haskell.org/D4344
      
      (cherry picked from commit 59fa7b32)
      c60c6590
  3. 22 Jan, 2018 2 commits
    • Ryan Scott's avatar
      Fix #14692 by correcting an off-by-one error in TcGenDeriv · 1d05e0c7
      Ryan Scott authored
      A silly mistake in `gen_Show_binds` was causing derived
      `Show` instances for empty data types to case on the precedence
      argument instead of the actual value being showed.
      
      Test Plan: make test TEST=drv-empty-data
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14692
      
      Differential Revision: https://phabricator.haskell.org/D4328
      
      (cherry picked from commit 0074a08e)
      1d05e0c7
    • John Ky's avatar
      Add new mbmi and mbmi2 compiler flags · b75f8d26
      John Ky authored
      This adds support for the bit deposit and extraction operations provided
      by the BMI and BMI2 instruction set extensions on modern amd64 machines.
      
      Implement x86 code generator for pdep and pext.  Properly initialise
      bmiVersion field.
      
      pdep and pext test cases
      
      Fix pattern match for pdep and pext instructions
      
      Fix build of pdep and pext code for 32-bit architectures
      
      Test Plan: Validate
      
      Reviewers: austin, simonmar, bgamari, angerman
      
      Reviewed By: bgamari
      
      Subscribers: trommler, carter, angerman, thomie, rwbarton, newhoggy
      
      GHC Trac Issues: #14206
      
      Differential Revision: https://phabricator.haskell.org/D4236
      
      (cherry picked from commit f8557696)
      b75f8d26
  4. 21 Jan, 2018 1 commit
    • Oleg Grenrus's avatar
      Update Cabal submodule · 61db0b89
      Oleg Grenrus authored
      - Cabal-2.2 uses SPDX license identifiers, so I had to update
        `cabal-version: 2.1` packages `license: BSD3` to
        `license: BSD-3-Clause`
      - `ghc-cabal` used old ReadP parsec, now it uses `parsec` too
      - InstalledPackageInfo pretty-printing have changed a little,
        fields with default values aren't printed. This can be changed in
        `Cabal` still, but I haven't found problems with omitting them.
      
      Note: `BSD-3-Clause` is parsed as "name = BSD, version = 3" by old
      parser (because 3-Clause looks like version 3 with tag Clause).
      If you see *"BSD-3" is not a valid license*, then something is using
      old parser still.
      
      Fixes #9885.
      
      (cherry picked from commit 5d6e0806c690ac1958e4cbf609bc6b18048fb761)
      61db0b89
  5. 18 Jan, 2018 3 commits
    • Ryan Scott's avatar
      Fix #14681 and #14682 with precision-aimed parentheses · 33e3b3eb
      Ryan Scott authored
      It turns out that `Convert` was recklessly leaving off
      parentheses in two places:
      
      * Negative numeric literals
      * Patterns in lambda position
      
      This patch fixes it by adding three new functions, `isCompoundHsLit`,
      `isCompoundHsOverLit`, and `isCompoundPat`, and using them in the
      right places in `Convert`. While I was in town, I also sprinkled
      `isCompoundPat` among some `Pat`-constructing functions in `HsUtils`
      to help avoid the likelihood of this problem happening in other
      places. One of these places is in `TcGenDeriv`, and sprinkling
      `isCompountPat` there fixes #14682
      
      Test Plan: make test TEST="T14681 T14682"
      
      Reviewers: alanz, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14681, #14682
      
      Differential Revision: https://phabricator.haskell.org/D4323
      
      (cherry picked from commit 575c009d)
      33e3b3eb
    • Matthías Páll Gissurarson's avatar
      Inform hole substitutions of typeclass constraints (fixes #14273). · 96b52e63
      Matthías Páll Gissurarson authored
      This implements SPJ's suggestion on the ticket (#14273). We find the
      relevant constraints (ones that whose free unification variables are all
      mentioned in the type of the hole), and then clone the free unification
      variables of the hole and the relevant constraints. We then add a
      subsumption constraints and run the simplifier, and then check whether
      all the constraints were solved.
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: RyanGlScott, rwbarton, thomie, carter
      
      GHC Trac Issues: #14273
      
      Differential Revision: https://phabricator.haskell.org/D4315
      
      (cherry picked from commit 1e14fd3e)
      96b52e63
    • Ryan Scott's avatar
      Improve treatment of sectioned holes · da83722c
      Ryan Scott authored
      Previously, GHC was pretty-printing left-section holes
      incorrectly and not parsing right-sectioned holes at all. This patch
      fixes both problems.
      
      Test Plan: make test TEST=T14590
      
      Reviewers: bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #14590
      
      Differential Revision: https://phabricator.haskell.org/D4273
      
      (cherry picked from commit 4d41e921)
      da83722c
  6. 17 Jan, 2018 1 commit
  7. 15 Jan, 2018 2 commits
    • Ryan Scott's avatar
      Parenthesize forall-type args in cvtTypeKind · b92fb515
      Ryan Scott authored
      Trac #14646 happened because we forgot to parenthesize `forall` types to
      the left of an arrow. This simple patch fixes that.
      
      Test Plan: make test TEST=T14646
      
      Reviewers: alanz, goldfire, bgamari
      
      Reviewed By: alanz
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14646
      
      Differential Revision: https://phabricator.haskell.org/D4298
      
      (cherry picked from commit f380115c)
      b92fb515
    • Simon Peyton Jones's avatar
      Fix join-point decision · 20afdaa7
      Simon Peyton Jones authored
      This patch moves the "ok_unfolding" test
         from  CoreOpt.joinPointBinding_maybe
         to    OccurAnal.decideJoinPointHood
      
      Previously the occurrence analyser was deciding to make
      something a join point, but the simplifier was reversing
      that decision, which made the decision about /other/ bindings
      invalid.
      
      Fixes Trac #14650.
      
      (cherry picked from commit 66ff794f)
      20afdaa7
  8. 14 Jan, 2018 7 commits
    • Simon Peyton Jones's avatar
      Fix two more bugs in partial signatures · 3d2664e4
      Simon Peyton Jones authored
      These were shown up by Trac #14643
      
      Bug 1: if we had a single partial signature for
      two functions
         f, g :: forall a. _ -> a
      then we made two different SigTvs but with the sane Name.
      This was jolly confusing and ultimately led to deeply bogus
      results with Any's appearing in the resulting program. Yikes.
      Fix: clone the quantified variables in TcSigs.tcInstSig (as
      indeed its name suggests).
      
      Bug 2: we were not eliminating duplicate/superclass constraints
      in the partial signatures of a mutually recursive group.
      
      Easy to fix: we are already doing dup/superclass elim in
      TcSimplify.decideQuantification.  So we move the partial-sig
      constraints there too.
      
      (cherry picked from commit 1577908f)
      3d2664e4
    • Ryan Scott's avatar
      Add regression test for #14040 · 0d406936
      Ryan Scott authored
      This adds a regression test for the original program in #14040.
      
      This does not fix #14040 entirely, though, as the program in
      https://ghc.haskell.org/trac/ghc/ticket/14040#comment:2 still
      panics, so there is more work to be done there.
      
      (cherry picked from commit be1ca0e4)
      0d406936
    • Simon Peyton Jones's avatar
      Drop dead Given bindings in setImplicationStatus · 5124b04f
      Simon Peyton Jones authored
      Trac #13032 pointed out that we sometimes generate unused
      bindings for Givens, and (worse still) we can't always discard
      them later (we don't drop a case binding unless we can prove
      that the scrutinee is non-bottom.
      
      It looks as if this may be a major reason for the performace
      problems in #14338 (see comment:29).
      
      This patch fixes the problem at source, by pruning away all the
      dead Givens.  See Note [Delete dead Given evidence bindings]
      
      Remarkably, compiler allocation falls by 23% in
      perf/compiler/T12227!
      
      I have not confirmed whether this change actualy helps with
      
      (cherry picked from commit 954cbc7c)
      5124b04f
    • Simon Peyton Jones's avatar
      Fix floating of equalities · 594879dc
      Simon Peyton Jones authored
      This rather subtle patch fixes Trac #14584.  The problem was
      that we'd allowed a coercion, bound in a nested scope, to escape
      into an outer scope.
      
      The main changes are
      
      * TcSimplify.floatEqualities takes more care when floating
        equalities to make sure we don't float one out that mentions
        a locally-bound coercion.
        See Note [What prevents a constraint from floating]
      
      * TcSimplify.emitResidualConstraints (which emits the residual
        constraints in simplifyInfer) now avoids burying the constraints
        for escaping CoVars inside the implication constraint.
      
      * Since I had do to this stuff with CoVars, I moved the
        fancy footwork about not quantifying over CoVars from
        TcMType.quantifyTyVars to its caller
        TcSimplify.decideQuantifiedTyVars.  I think its other
        callers don't need to worry about all this CoVar stuff.
      
      This turned out to be surprisigly tricky, and took me a solid
      day to get right.  I think the result is reasonably neat, though,
      and well documented with Notes.
      
      (cherry picked from commit f5cf9d1a)
      594879dc
    • Simon Peyton Jones's avatar
      Refactor coercion holes · b586f77b
      Simon Peyton Jones authored
      In fixing Trac #14584 I found that it would be /much/ more
      convenient if a "hole" in a coercion (much like a unification
      variable in a type) acutally had a CoVar associated with it
      rather than just a Unique.  Then I can ask what the free variables
      of a coercion is, and get a set of CoVars including those
      as-yet-un-filled in holes.
      
      Once that is done, it makes no sense to stuff coercion holes
      inside UnivCo.  They were there before so we could know the
      kind and role of a "hole" coercion, but once there is a CoVar
      we can get that info from the CoVar.  So I removed HoleProv
      from UnivCoProvenance and added HoleCo to Coercion.
      
      In summary:
      
      * Add HoleCo to Coercion and remove HoleProv from UnivCoProvanance
      
      * Similarly in IfaceCoercion
      
      * Make CoercionHole have a CoVar in it, not a Unique
      
      * Make tyCoVarsOfCo return the free coercion-hole variables
        as well as the ordinary free CoVars.  Similarly, remember
        to zonk the CoVar in a CoercionHole
      
      We could go further, and remove CoercionHole as a distinct type
      altogther, just collapsing it into HoleCo.  But I have not done
      that yet.
      
      (cherry picked from commit a492af06)
      b586f77b
    • Simon Peyton Jones's avatar
      Check for bogus quantified tyvars in partial type sigs · 87e517c1
      Simon Peyton Jones authored
      This fixes Trac #14479.  Not difficult.
      
      See Note [Quantification and partial signatures] Wrinkle 4,
      in TcSimplify.
      
      (cherry picked from commit 72938f58)
      87e517c1
    • Simon Peyton Jones's avatar
      Fix SigTvs at the kind level · 40a31b38
      Simon Peyton Jones authored
      This patch fixes two bugs in the treatment of SigTvs at the
      kind level:
      
      - We should always generalise them, never default them
        (Trac #14555, #14563)
      
      - We should check if they get unified with each other
        (Trac #11203)
      
      Both are described in TcHsType
         Note [Kind generalisation and SigTvs]
      
      (cherry picked from commit 8361b2c5)
      40a31b38
  9. 12 Jan, 2018 2 commits
    • Ryan Scott's avatar
      Make typeToLHsType produce kind signatures for tycon applications · ebf8e076
      Ryan Scott authored
      Summary:
      `GeneralizedNewtypeDeriving` generates calls to `coerce`
      which take visible type arguments. These types must be produced by
      way of `typeToLHsType`, which converts a `Type` to an `LHsType`.
      However, `typeToLHsType` was leaving off important kind information
      when a `Type` contained a poly-kinded tycon application, leading to
      incorrectly generated code in #14579.
      
      This fixes the issue by tweaking `typeToLHsType` to generate
      explicit kind signatures for tycon applications. This makes the
      generated code noisier, but at least the program from #14579 now
      works correctly.
      
      Test Plan: make test TEST=T14579
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14579
      
      Differential Revision: https://phabricator.haskell.org/D4264
      
      (cherry picked from commit 649e7772)
      ebf8e076
    • Ryan Scott's avatar
      Fix #14578 by checking isCompoundHsType in more places · e32f5827
      Ryan Scott authored
      Summary:
      The `HsType` pretty-printer does not automatically insert
      parentheses where necessary for type applications, so a function
      `isCompoundHsType` was created in D4056 towards this purpose.
      However, it was not used in as many places as it ought to be,
      resulting in #14578.
      
      Test Plan: make test TEST=T14578
      
      Reviewers: alanz, bgamari, simonpj
      
      Reviewed By: alanz, simonpj
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #14578
      
      Differential Revision: https://phabricator.haskell.org/D4266
      
      (cherry picked from commit 1bd91a7a)
      e32f5827
  10. 04 Jan, 2018 1 commit
    • Ryan Scott's avatar
      Fix #14608 by restoring an unboxed tuple check · ec6af9c4
      Ryan Scott authored
      Commit 714bebff removed
      a check in the bytecode compiler that caught illegal uses of unboxed
      tuples (and now sums) in case alternatives, which causes the program
      in #14608 to panic. This restores the check (using modern,
      levity-polymorphic vocabulary).
      
      Test Plan: make test TEST=T14608
      
      Reviewers: hvr, bgamari, dfeuer, simonpj
      
      Reviewed By: dfeuer, simonpj
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #14608
      
      Differential Revision: https://phabricator.haskell.org/D4276
      
      (cherry picked from commit ecff651f)
      ec6af9c4
  11. 28 Dec, 2017 1 commit
    • Richard Eisenberg's avatar
      Fix #14618 by applying a subst in deeplyInstantiate · 1779e3bf
      Richard Eisenberg authored
      Previously, we were inexplicably not applying an instantiating
      substitution to arguments in non-prenex types. It's amazing this
      has been around for so long! I guess there aren't a lot of non-prenex
      types around.
      
      test case: typecheck/should_fail/T14618
      
      (cherry picked from commit 722a6584)
      1779e3bf
  12. 14 Dec, 2017 1 commit
    • carlostome's avatar
      Fix #14135 by validity checking matches · cc034b35
      carlostome authored
      We filter the complete patterns given in a COMPLETE set to only those that
      subsume the type we are matching. Otherwise we end up introducing an ill-typed
      equation into the overlap checking, provoking a crash. This was the cause of
      Trac #14135.
      
      Reviewers: austin, bgamari, mpickering, gkaracha, simonpj, RyanGlScott,
      carlostome
      
      Reviewed By: bgamari
      
      Subscribers: carter, dfeuer, RyanGlScott, goldfire, rwbarton, thomie
      
      GHC Trac Issues: #14135
      
      Differential Revision: https://phabricator.haskell.org/D3981
      
      (cherry picked from commit 16c7d9dc)
      cc034b35
  13. 11 Dec, 2017 1 commit
    • David Feuer's avatar
      Allow users to ignore optimization changes · 6fd8629d
      David Feuer authored
      * Add a new flag, `-fignore-optim-changes`, allowing them to avoid
        recompilation if the only changes are to the `-O` level or to
        flags controlling optimizations.
      
      * When `-fignore-optim-changes` is *off*, recompile when optimization
        flags (e.g., `-fno-full-laziness`) change. Previously, we ignored
        these unconditionally when deciding whether to recompile a module.
      
      Reviewers: austin, bgamari, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: duog, carter, simonmar, rwbarton, thomie
      
      GHC Trac Issues: #13604
      
      Differential Revision: https://phabricator.haskell.org/D4123
      
      (cherry picked from commit 708ed9ca)
      6fd8629d
  14. 01 Dec, 2017 3 commits
    • David Feuer's avatar
      Cache TypeRep kinds aggressively · bc761ad9
      David Feuer authored
      Cache `TypeRep k` in each `TrApp` or `TrTyCon` constructor of
      `TypeRep (a :: k)`. This makes `typeRepKind` cheap.
      
      With this change, we won't need any special effort to deserialize
      typereps efficiently. The downside, of course, is that we make
      `TypeRep`s slightly larger.
      
      Reviewers: austin, hvr, bgamari, simonpj
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: carter, simonpj, rwbarton, thomie
      
      GHC Trac Issues: #14254
      
      Differential Revision: https://phabricator.haskell.org/D4085
      bc761ad9
    • Edward Z. Yang's avatar
      Handle CPP properly in Backpack · e1fb2838
      Edward Z. Yang authored
      
      
      Summary:
      Previously, we attempted to lookup 'hole' packages for
      include directories; this obviously is not going to work.
      Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@fb.com>
      
      Test Plan: validate
      
      Reviewers: ekmett, bgamari
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14525
      
      Differential Revision: https://phabricator.haskell.org/D4234
      e1fb2838
    • Edward Z. Yang's avatar
      Make use of boot TyThings during typechecking. · 69987720
      Edward Z. Yang authored
      
      
      Summary:
      Suppose that you are typechecking A.hs, which transitively imports,
      via B.hs, A.hs-boot.  When we poke on B.hs and discover that it
      has a reference to a type from A, what TyThing should we wire
      it up with?  Clearly, if we have already typechecked A, we
      should use the most up-to-date TyThing: the one we freshly
      generated when we typechecked A.  But what if we haven't typechecked
      it yet?
      
      For the longest time, GHC adopted the policy that this was
      *an error condition*; that you MUST NEVER poke on B.hs's reference
      to a thing defined in A.hs until A.hs has gotten around to checking
      this.  However, actually ensuring this is the case has proven
      to be a bug farm.  The problem was especially poignant with
      type family consistency checks, which eagerly happen before
      any typechecking takes place.
      
      This patch takes a different strategy: if we ever try to access
      an entity from A which doesn't exist, we just fall back on the
      definition of A from the hs-boot file.  This means that you may
      end up with a mix of A.hs and A.hs-boot TyThings during the
      course of typechecking.
      Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@fb.com>
      
      Test Plan: validate
      
      Reviewers: simonpj, bgamari, austin, goldfire
      
      Subscribers: thomie, rwbarton
      
      GHC Trac Issues: #14396
      
      Differential Revision: https://phabricator.haskell.org/D4154
      69987720
  15. 28 Nov, 2017 1 commit
  16. 27 Nov, 2017 3 commits
  17. 22 Nov, 2017 4 commits
  18. 21 Nov, 2017 1 commit
    • Ben Gamari's avatar
      Revert "trees that grow" work · 314bc314
      Ben Gamari authored
      As documented in #14490, the Data instances currently blow up
      compilation time by too much to stomach. Alan will continue working on
      this in a branch and we will perhaps merge to 8.2 before 8.2.1 to avoid
      having to perform painful cherry-picks in 8.2 minor releases.
      
      Reverts haddock submodule.
      
      This reverts commit 47ad6578.
      This reverts commit e3ec2e7a.
      This reverts commit 438dd1cb.
      This reverts commit 0ff152c9.
      314bc314
  19. 18 Nov, 2017 1 commit
    • niteria's avatar
      Fix T4437 · 912a72d2
      niteria authored
      This test tests if the flags are in sync between GHC and
      Cabal.
      After b0b80e90 'Implement the basics of hex floating point
      literals' landed, the Cabal side had to be updated. That
      has been done, and 835d8ddb 'GHC.Prim use virtual-modules'
      brought the Cabal submodule up to date.
      912a72d2
  20. 15 Nov, 2017 1 commit
    • Peter Trommler's avatar
      RTS: Disable warnings in ffi.h · 8b1020ed
      Peter Trommler authored
      The update of GHC's in-tree libffi causes warnings about
      undefined macros and hence validate fails.
      
      Also mark broken tests that have a ticket.
      
      Fixes #14353
      
      Test Plan: ./validate (on AIX and powerpc if possible)
      
      Reviewers: bgamari, hvr, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: snowleopard, rwbarton, thomie
      
      GHC Trac Issues: #14353, #11259, #14455, #11261
      
      Differential Revision: https://phabricator.haskell.org/D4181
      8b1020ed