1. 15 Jan, 2018 3 commits
    • Ben Gamari's avatar
      Support LIBRARY_PATH and LD_LIBRARY_PATH in rts · 87917a59
      Ben Gamari authored
      `LIBRARY_PATH` is used to find libraries and other link artifacts while
      `LD_LIBRARY_PATH` is used to find shared libraries by the loader.
      
      Due to an implementation detail on Windows, using `LIBRARY_PATH` will
      automatically add the path of any library found to the loader's path.
      
      So in that case `LD_LIBRARY_PATH` won't be needed.
      
      Test Plan:
      ./validate along with T14611 which has been made Windows only
      due to linux using the system linker/loader by default. So I feel a
      testcase there is unwarranted as the support is indirect via glibc.
      
      Reviewers: hvr, bgamari, erikd, simonmar, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, rwbarton, thomie, carter
      
      GHC Trac Issues: #14611
      
      Differential Revision: https://phabricator.haskell.org/D4275
      87917a59
    • David Feuer's avatar
      Kill off irrefutable pattern errors · 492e6044
      David Feuer authored
      Distinguishing between "refutable" and "irrefutable" patterns
      (as described by the Haskell Report) in incomplete pattern errors
      was more confusing than helpful. Remove references to irrefutable
      patterns.
      
      Reviewers: hvr, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #14569
      
      Differential Revision: https://phabricator.haskell.org/D4261
      492e6044
    • Matthew Pickering's avatar
      Rename -frule-check to -drule-check and document · d1ac1c33
      Matthew Pickering authored
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4256
      d1ac1c33
  2. 12 Jan, 2018 1 commit
    • Alec Theriault's avatar
      Support constructor Haddocks in more places · e20046a0
      Alec Theriault authored
      This adds support for adding Haddocks on individual non-record fields
      of regular (and GADT) constructors. The following now parses just fine
      with `-haddock` enabled:
      
      data Foo
        = Baz             -- ^ doc on the `Baz` constructor
            Int           -- ^ doc on the `Int` field of `Baz`
            String        -- ^ doc on the `String` field of `Baz`
      
        | Int             -- ^ doc on the `Int` field of the `:*` constructor
            :*            -- ^ doc on the `:*` constructor
          String          -- ^ doc on the `String` field of the `:*`
      constructor
      
        | Boa             -- ^ doc on the `Boa` record constructor
            { y :: () }
      
      The change is backwards compatible: if there is only one doc and it
      occurs
      on the last field, it is lifted to apply to the whole constructor (as
      before).
      
      Reviewers: bgamari, alanz
      
      Subscribers: rwbarton, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4292
      e20046a0
  3. 10 Jan, 2018 1 commit
    • niteria's avatar
      Lift constructor tag allocation out of a loop · dbdf77d9
      niteria authored
      Before this change, for each constructor that we want
      to allocate a tag for we would traverse a list of all
      the constructors in a datatype to determine which tag
      a constructor should get.
      
      This is obviously quadratic and for datatypes with 10k
      constructors it actually makes a big difference.
      
      This change implements the plan outlined by @simonpj in
      https://mail.haskell.org/pipermail/ghc-devs/2017-October/014974.html
      which is basically about using a map and constructing it outside the
      loop.
      
      One place where things got a bit awkward was TysWiredIn.hs,
      it would have been possible to just assign the tags by hand, but
      that seemed error-prone to me, so I decided to go through a map
      there as well.
      
      Test Plan:
      ./validate
      On a file with 10k constructors
      Before:
         8,130,522,344 bytes allocated in the heap
        Total   time    3.682s  (  3.920s elapsed)
      After:
         4,133,478,744 bytes allocated in the heap
        Total   time    2.509s  (  2.750s elapsed)
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: goldfire, rwbarton, thomie, simonmar, carter, simonpj
      
      GHC Trac Issues: #14657
      
      Differential Revision: https://phabricator.haskell.org/D4289
      dbdf77d9
  4. 09 Jan, 2018 2 commits
    • Simon Peyton Jones's avatar
      Fix two more bugs in partial signatures · 1577908f
      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.
      1577908f
    • Simon Peyton Jones's avatar
      Fix join-point decision · 66ff794f
      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.
      66ff794f
  5. 08 Jan, 2018 1 commit
    • Simon Marlow's avatar
      Improve accuracy of get/setAllocationCounter · a1a689dd
      Simon Marlow authored
      Summary:
      get/setAllocationCounter didn't take into account allocations in the
      current block. This was known at the time, but it turns out to be
      important to have more accuracy when using these in a fine-grained
      way.
      
      Test Plan:
      New unit test to test incrementally larger allocaitons.  Before I got
      results like this:
      
      ```
      +0
      +0
      +0
      +0
      +0
      +4096
      +0
      +0
      +0
      +0
      +0
      +4064
      +0
      +0
      +4088
      +4056
      +0
      +0
      +0
      +4088
      +4096
      +4056
      +4096
      ```
      
      Notice how the results aren't always monotonically increasing.  After
      this patch:
      
      ```
      +344
      +416
      +488
      +560
      +632
      +704
      +776
      +848
      +920
      +992
      +1064
      +1136
      +1208
      +1280
      +1352
      +1424
      +1496
      +1568
      +1640
      +1712
      +1784
      +1856
      +1928
      +2000
      +2072
      +2144
      ```
      
      Reviewers: niteria, bgamari, hvr, erikd
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4288
      a1a689dd
  6. 05 Jan, 2018 2 commits
  7. 04 Jan, 2018 3 commits
    • Simon Peyton Jones's avatar
      Fix deep, dark corner of pattern synonyms · 307d1dfe
      Simon Peyton Jones authored
      Trac #14552 showed a very obscure case where we can't infer a
      good pattern-synonym type.
      
      The error message is horrible, but at least we no longer crash
      and burn.
      307d1dfe
    • Simon Peyton Jones's avatar
      Drop dead Given bindings in setImplicationStatus · 954cbc7c
      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
      954cbc7c
    • Ryan Scott's avatar
      Make typeToLHsType produce kind signatures for tycon applications · 649e7772
      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
      649e7772
  8. 03 Jan, 2018 3 commits
    • Simon Peyton Jones's avatar
      No deferred type errors under a forall · 298ec78c
      Simon Peyton Jones authored
      As Trac #14605 showed, we can't defer a type error under a
      'forall' (when unifying two forall types).
      
      The fix is simple.
      298ec78c
    • Simon Peyton Jones's avatar
      Get evaluated-ness right in the back end · bd438b2d
      Simon Peyton Jones authored
      See Trac #14626, comment:4.  We want to maintain evaluted-ness
      info on Ids into the code generateor for two reasons
      (see Note [Preserve evaluated-ness in CorePrep] in CorePrep)
      
      - DataToTag magic
      - Potentially using it in the codegen (this is Gabor's
        current work)
      
      But it was all being done very inconsistently, and actually
      outright wrong -- the DataToTag magic hasn't been working for
      years.
      
      This patch tidies it all up, with Notes to match.
      bd438b2d
    • Simon Peyton Jones's avatar
      Fix OptCoercion · 9e5535ca
      Simon Peyton Jones authored
      In the presence of -fdefer-type-errors, OptCoercion can
      encounter a mal-formed coerercion with type
          T a ~ T a b
      and that was causing a subsequent Lint error.
      
      This caused Trac #14607.  Easily fixed by turning an ASSERT
      into a guard.
      9e5535ca
  9. 02 Jan, 2018 3 commits
    • Matthew Pickering's avatar
      Rename HEq_sc and Coercible_sc to heq_sel and coercible_sel · 3382ade3
      Matthew Pickering authored
      These functions are record selectors.
      
      To the unfamiliar, when inspecting core, they looked like data
      constructors as they started with an upper case letter. We rename them
      so that it is more clear that firstly they are functions and secondly
      that they are selectors.
      
      Reviewers: bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4280
      3382ade3
    • Ryan Scott's avatar
      Fix #14608 by restoring an unboxed tuple check · ecff651f
      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
      ecff651f
    • Tamar Christina's avatar
      Windows: fix all failing tests. · 27b7b4db
      Tamar Christina authored
      This makes the testsuite pass clean on Windows again.
      It also fixes the `libstdc++-6.dll` error harbormaster
      was showing.
      
      I'm marking some tests as isolated tests to reduce their
      flakiness (mostly concurrency tests) when the test system
      is under heavy load.
      
      Updates process submodule.
      
      Test Plan: ./validate
      
      Reviewers: hvr, bgamari, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4277
      27b7b4db
  10. 26 Dec, 2017 1 commit
    • Richard Eisenberg's avatar
      Fix #14618 by applying a subst in deeplyInstantiate · 722a6584
      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
      722a6584
  11. 21 Dec, 2017 7 commits
    • Gabor Greif's avatar
      Typos in comments · bcb519c5
      Gabor Greif authored
      bcb519c5
    • Simon Peyton Jones's avatar
      Fix floating of equalities · f5cf9d1a
      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.
      f5cf9d1a
    • Simon Peyton Jones's avatar
      Check for bogus quantified tyvars in partial type sigs · 72938f58
      Simon Peyton Jones authored
      This fixes Trac #14479.  Not difficult.
      
      See Note [Quantification and partial signatures] Wrinkle 4,
      in TcSimplify.
      72938f58
    • Ryan Scott's avatar
      Improve treatment of sectioned holes · 4d41e921
      Ryan Scott authored
      Summary:
      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
      4d41e921
    • Ryan Scott's avatar
      Remove hack put in place for #12512 · 9cb289ab
      Ryan Scott authored
      Summary:
      Previously, I added an ad hoc check for unboxed tuples and
      sums in standalone-derived instances to fix #12512, under the
      pretense that polymorphism over `UnboxedTupleRep` and
      `UnboxedSumRep` was a lie. But that is no longer the case, and so
      this ad hoc check can be removed entirely. Less code, and easier to
      understand.
      
      Test Plan: make test TEST=T12512
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4271
      9cb289ab
    • Ryan Scott's avatar
      Fix #14588 by checking for more bang patterns · 9caf40e9
      Ryan Scott authored
      Summary:
      Commit 37299536
      inadvertently removed a check in the parser which rejected
      let-bindings with bang patterns, leading to #14588. This fixes it by
      creating a `hintBangPat` function to perform this check, and
      sprinkling it in the right places.
      
      Test Plan: make test TEST=T14588
      
      Reviewers: bgamari, alanz, simonpj
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #14588
      
      Differential Revision: https://phabricator.haskell.org/D4270
      9caf40e9
    • Ryan Scott's avatar
      Fix #14578 by checking isCompoundHsType in more places · 1bd91a7a
      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
      1bd91a7a
  12. 19 Dec, 2017 1 commit
  13. 18 Dec, 2017 5 commits
  14. 15 Dec, 2017 1 commit
    • Simon Peyton Jones's avatar
      Fix tcDataKindSig · 68149452
      Simon Peyton Jones authored
      This patch fixes an outright bug in tcDataKindSig, shown up in Trac
      of a data type declaration.  See Note [TyConBinders for the result kind
      signature of a data type]
      
      I also took the opportunity to elminate the DataKindCheck argument
      and data type from tcDataKindSig, instead moving the check to the
      call site, which is easier to understand.
      68149452
  15. 14 Dec, 2017 3 commits
    • carlostome's avatar
      Fix #14135 by validity checking matches · 16c7d9dc
      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
      16c7d9dc
    • Simon Peyton Jones's avatar
      Fix an outright bug in the unflattener · b1ea0475
      Simon Peyton Jones authored
      Trac #14554 showed up an outright bug in the unflattening code in
      TcFlatten.  I was filling in a coercion with the wrong coercion (a Syn
      in the wrong place).  Result: "Bad coercion hole" assertion failures,
      and Core Lint Errors.
      
      Easily fixed, and the code is simpler too.
      b1ea0475
    • Simon Peyton Jones's avatar
      Add test for Trac #14580 · 6f6d1050
      Simon Peyton Jones authored
      6f6d1050
  16. 13 Dec, 2017 3 commits
    • Simon Peyton Jones's avatar
      Further improvements to well-kinded types · 0a12d92a
      Simon Peyton Jones authored
      The typechecker has the invariant that every type should be well-kinded
      as it stands, without zonking.  See Note [The well-kinded type invariant]
      in TcType.
      
      That invariant was not being upheld, which led to Trac #14174.  I fixed
      part of it, but T14174a showed that there was more.  This patch finishes
      the job.
      
      * See Note [The tcType invariant] in TcHsType, which articulates an
        invariant that was very nearly, but not quite, true.  One place that
        falisified it was the HsWildCardTy case of tc_hs_type, so I fixed that.
      
      * mkNakedCastTy now makes no attempt to eliminate casts; indeed it cannot
        lest it break Note [The well-kinded type invariant].  The prior comment
        suggested that it was crucial for performance but happily it seems not
        to be. The extra Refls are eliminated by the zonker.
      
      * I found I could tidy up TcHsType.instantiateTyN and instantiateTyUntilN
        by eliminating one of its parameters.  That led to a cascade of minor
        improvements in TcTyClsDecls. Hooray.
      0a12d92a
    • Simon Peyton Jones's avatar
      Re-centre perf for T5321Fun · 63e968a9
      Simon Peyton Jones authored
      Bytes allocated has fallen by around 5%. I think this due
      to some of my recent refactoring of the typechecker, but
      I'm not certain about exactly which change did it.
      
      Good though!
      63e968a9
    • Simon Peyton Jones's avatar
      Add missing stderr for Trac #14561 · aef4dee8
      Simon Peyton Jones authored
      aef4dee8