1. 18 Oct, 2016 1 commit
    • Simon Peyton Jones's avatar
      Correct order of existentials in pattern synonyms · 5c02b842
      Simon Peyton Jones authored
      Trac #12698 exposed a nasty bug in the typechecking for
      pattern synonmys: the existential type variables weren't
      being put in properly-scoped order.
      For some reason TcPatSyn.tcCollectEx was colleting them as a
      set, not as a list!  Easily fixed.
      (cherry picked from commit a693d1cb)
  2. 14 Oct, 2016 4 commits
  3. 13 Oct, 2016 5 commits
    • Ryan Scott's avatar
      Add test for #12456 · 243994c3
      Ryan Scott authored
      Commit f352e5cd fixed #12456. Let's add a test
      to make sure it stays fixed.
      (cherry picked from commit fef1df4b)
    • Ben Gamari's avatar
    • Simon Marlow's avatar
      Fix an assertion that could randomly fail · b7d6e20c
      Simon Marlow authored
      ASSERT_THREADED_CAPABILITY_INVARIANTS was testing properties of the
      returning_tasks queue, but that requires cap->lock to access safely.
      This assertion would randomly fail if stressed enough.
      Instead I've removed it from the catch-all
      ASSERT_PARTIAL_CAPABILITIY_INVARIANTS and made it a separate assertion
      only called under cap->lock.
      Test Plan:
      cd testsuite/tests/concurrent/should_run
      make TEST=setnumcapabilities001 WAY=threaded1 EXTRA_HC_OPTS=-with-rtsopts=-DS CLEANUP=0
      while true; do ./setnumcapabilities001.run/setnumcapabilities001 4 9 2000 || break; done
      Reviewers: niteria, bgamari, ezyang, austin, erikd
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2440
      GHC Trac Issues: #10860
      (cherry picked from commit ce13a9a9)
    • Ben Gamari's avatar
      validate: Add --build-only · 5230fa04
      Ben Gamari authored
      This will allow us to split up Harbormaster output for the build and
      test stages of validation.
      Test Plan: `./validate --build-only && ./validate --testsuite-only`
      Reviewers: thomie, hvr, austin
      Differential Revision: https://phabricator.haskell.org/D2553
      (cherry picked from commit 4d2b15d5)
    • Simon Peyton Jones's avatar
      Fix impredicativity (again) · c93ad554
      Simon Peyton Jones authored
      This patch fixes Trac #12616.
      Dignosis.  In TcUnify.tc_sub_type_ds we were going to some trouble to
      support co- and contra-variance even for impredicative types.  With
      -XImpredicativeTYpes, this allowed a unification variable to be
      unified with a polytype (probably wrongly) and that caused later
      trouble in the constraint solver, where -XImpredicativeTypes was /not/
      on.  In effect, -XImpredicativeTypes can't be switched on locally.
      Why did we want ImpredicativeTypes locally?  Because the program
      generated by GND for a higher-rank method involved impredicative
      instantation of 'coerce':
            op = coerce op   -- where op has a higher rank type
      See Note [Newtype-deriving instances] in TcGenDeriv.
      1.  It is ghastly to rely on ImpredicativeTypes (a 100% flaky
          feature) to instantiate coerce polymorphically.  Happily we
          now have Visible Type Application, so I've used that instead
          which should be solid and reliable.
      2.  I deleted the code in tc_sub_type_ds that allows the constraint
          solver to "look through" a unification variable to find a
          polytype.  That used to be essential in the days of ReturnTv,
          but it's utterly unreliable and should be consigned to the dustbin
          of history.  (We have ExpType now for the essential uses.)
      Tests involving ImpredicativeTypes are affected, but I'm not worried
      about them... it's advertised as a feature you can't rely on, and
      I want to reform it outright.
      (cherry picked from commit b612da66)
  4. 12 Oct, 2016 3 commits
    • Simon Peyton Jones's avatar
      Some tiding up in TcGenDeriv · cec50665
      Simon Peyton Jones authored
      ..around newtype deriving instances.
      See esp the new Note [Newtype-deriving instances]
      No change in behaviour
      (cherry picked from commit 96d45145)
    • Simon Peyton Jones's avatar
      Add derived shadows only for Wanted constraints · fefc5301
      Simon Peyton Jones authored
      This patch implements choice (3) of comment:14 on Trac #12660.
      It cures an infinite loop (caused by the creation of an infinite
      type) in in compiling the 'singletons' package.
      See Note [Add derived shadows only for Wanteds] in TcSMonad.
      (cherry picked from commit 8fa5f5b1)
    • Ben Gamari's avatar
      RnExpr: Actually fail if patterns found in expression · 47ae01bf
      Ben Gamari authored
      This fixes #12584, where wildcard patterns were snuck into an
      expression, which then crashed the typechecker in TcExpr since EWildPats
      aren't supposed to appear in the AST after renaming.
      The problem was that `rnTopSpliceDecl` failed to check for errors from
      `rnSplice` (as done by other callers to `rnSplice`).
      Thanks to Shayan for reporting this!
      Reviewers: simonpj, austin
      Reviewed By: simonpj
      Subscribers: simonpj, thomie
      Differential Revision: https://phabricator.haskell.org/D2539
      GHC Trac Issues: #12584
      (cherry picked from commit bce99086)
  5. 10 Oct, 2016 9 commits
    • Ben Gamari's avatar
      Fix test output · f168a616
      Ben Gamari authored
    • Facundo Domínguez's avatar
      Don't ignore addTopDecls in module finalizers. · a77bbb8b
      Facundo Domínguez authored
      Module finalizer could call addTopDecls, however, the declarations
      added in this fashion were ignored. This patch makes sure to rename,
      type check and incorporate this declarations.
      Because a declaration may include a splice which calls addModFinalizer,
      the list of finalizers is repeteadly checked after adding declarations
      until no more finalizers remain.
      Test Plan: ./validate
      Reviewers: bgamari, goldfire, simonpj, austin
      Reviewed By: bgamari, simonpj
      Subscribers: simonmar, mboes, thomie
      Differential Revision: https://phabricator.haskell.org/D2505
      GHC Trac Issues: #12559
      (cherry picked from commit 71dd6e44)
    • Edward Z. Yang's avatar
      Remove reexports from ghc-boot, help bootstrap with GHC 8. · bdfb9012
      Edward Z. Yang authored
      (cherry picked from commit 940ded85)
    • Moritz Angermann's avatar
      Do not segfault if no common root can be found · ec055513
      Moritz Angermann authored
      When trying to profile a plugin, ghc mysteriously segfaulted.  Upon
      closer examination the segfault happend due to a `->prevStack` lookup
      on a NULL pointer.
      A new CostCentre: Unknown is introduced that is set, if ccsapp and
      ccsfn are of equal depth (e.g. 0), and do not have a common CostCentre
      in their stacks.
      Reviewers: bgamari, simonmar, austin, erikd
      Reviewed By: simonmar
      Subscribers: Phyx, thomie
      Differential Revision: https://phabricator.haskell.org/D2551
      (cherry picked from commit bcd34451)
    • niteria's avatar
      Fix memory leak from #12664 · b08ffec0
      niteria authored
      This fixes the leak with `setProgArgv`. The problem was
      that `setProgArgv` would not free the objects pointed
      to by `prog_argc`, `prog_argv` when the globals were
      changed resulting in a leak.
      The only strictly necessary change is in `rts/RtsFlags.c`, but
      the code in `System.Environment` was a bit confusing and not
      exception safe, so I refactored it.
      Test Plan: ./validate
      Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2576
      GHC Trac Issues: #12664
      (cherry picked from commit e41b9c61)
    • Matthew Pickering's avatar
      Add missing test from D2545 · 7643c149
      Matthew Pickering authored
      This was somehow dropped from the original merge.
      Differential Revision: https://phabricator.haskell.org/D2545
      GHC Trac Issues: #12615
      (cherry picked from commit 1851349a)
    • Simon Peyton Jones's avatar
      More tests for Trac #12522 · 801cbb42
      Simon Peyton Jones authored
      These ones test the variations in coment:15 of the ticket
      (cherry picked from commit a6111b8c)
    • Simon Peyton Jones's avatar
      Orient improvement constraints better · 12cfcbeb
      Simon Peyton Jones authored
      This patch fixes an infinite loop in the constraint solver,
      shown up by Trac #12522.
      The solution is /very/ simple: just reverse the orientation of the
      derived constraints arising from improvement using type-family
      injectivity.  I'm not very proud of the fix --- it seems fragile
      --- but it has the very great merit of simplicity, and it works
      See Note [Improvement orientation] in TcInteract, and some
      discussion on the Trac ticket.
      (cherry picked from commit b255ae7b)
    • Simon Peyton Jones's avatar
      Improve error handling in TcRnMonad · 5662ceae
      Simon Peyton Jones authored
      See Note [Constraints and errors] in TcRnMonad.  This
      patch fixes Trac #12124 in quite a neat way.
      (cherry picked from commit 465c6c5d)
  6. 09 Oct, 2016 1 commit
  7. 02 Oct, 2016 17 commits
    • Ben Gamari's avatar
      runghc: Fix import of System.Process on Windows · 9cc5a8f4
      Ben Gamari authored
      This apparently should have been an import of rawSystem instead of
      runProcess. Oops.
      Fixes D2538.
      Test Plan: Validate on Linux and Windows.
      Reviewers: austin, snowleopard
      Reviewed By: snowleopard
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2561
      (cherry picked from commit 8952cc3e)
    • Michael Snoyman's avatar
      runghc: use executeFile to run ghc process on POSIX · c9042583
      Michael Snoyman authored
      This means that, on POSIX systems, there will be only one ghc process
      used for running scripts, as opposed to the current situation of a
      runghc process and a ghc process. Beyond minor performance benefits of
      not having an extra fork and resident process, the more important impact
      of this is automatically getting proper signal handling. I noticed this
      problem myself when running runghc as PID1 inside a Docker container.
      I attempted to create a shim library for executeFile that would work for
      both POSIX and Windows, but unfortunately I ran into issues with exit
      codes being propagated correctly (see
      https://github.com/fpco/replace-process/issues/2). Therefore, this patch
      leaves the Windows behavior unchanged. Given that signals are a POSIX
      issue, this isn't too bad a trade-off. If someone has suggestions for
      better Windows _exec support, please let me know.
      Reviewers: erikd, austin, bgamari
      Reviewed By: bgamari
      Subscribers: Phyx, thomie
      Differential Revision: https://phabricator.haskell.org/D2538
      (cherry picked from commit 42f1d867)
    • Ben Gamari's avatar
      Fix expected output for T7786 · a24092ff
      Ben Gamari authored
      I believe this is a benign difference between master and ghc-8.0.
    • Nicolas Trangez's avatar
      Turn `__GLASGOW_HASKELL_LLVM__` into an integer again · 3b13a042
      Nicolas Trangez authored
      In GHC < 8.0.1, the value of `__GLASGOW_HASKELL_LLVM__`, exposed
      through the preprocessor when compiled with `-fllvm`, was an integer
      value, encoded according to some rules specified in the user guide.
      Due to an oversight, in GHC 8.0.1 the value of this define became a
      tuple, exposed as e.g. `(3, 7)`. This was an unintended regression.
      This patch turns the value of the `__GLASGOW_HASKELL_LLVM__` definition
      into a single integer again, but changes the formatting of said number
      slightly. Before, any LLVM version where the major or minor component >=
      10 would cause ambiguous values for `__GLASGOW_HASKELL_LLVM__`. With
      this patch, the value is in line with `__GLASGOW_HASKELL__`, adding a
      padding `0` in-between major and minor component if applicable (we
      assume no minors >= 100 will ever exist).
      The documentation in the user guide is updated accordingly, and a
      reference is made in the 8.0.2 release notes.
      Test Plan: validate
      Reviewers: bgamari, erikd
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2552
      GHC Trac Issues: #12628
      (cherry picked from commit b0d53a83)
    • Ben Gamari's avatar
      Fix T12593 · 4557d944
      Ben Gamari authored
      (cherry picked from commit 779bcc90cf8a52270bcd70a82442d01d35d7c788)
    • Ben Gamari's avatar
      Fix T12512 · 15df5170
      Ben Gamari authored
    • Simon Peyton Jones's avatar
      Fix a bug in occurs checking · 836f0e24
      Simon Peyton Jones authored
      1. Trac #12593 exposed a long-standing bug in the occurs
         checking machinery.  When unifying two type variables
                a ~ b
         where a /= b, we were assuming that there could be
         no occurs-check error.  But there can: 'a' can occur
         in b's kind!  When the RHS was a non-tyvar we used
         occurCheckExpand, which /did/ look in kinds, but not
         when the RHS was a tyvar.
         This bug has been lurking ever since TypeInType, maybe
         longer.  And it was present both in TcUnify (the on-the-fly
         unifier), and in TcInteract.
         I ended up refactoring both so that the tyvar/tyvar
         path naturally goes through the same occurs-check as
         non-tyvar rhss.  It's simpler and more robust now.
         One good thing is that both unifiers now share
         previously they had different logic for the same goals
      2. Fixing this bug exposed another!  In T11635 we end
         up unifying
         (alpha :: forall k. k->*) ~ (beta :: forall k. k->*)
         Now that the occurs check is done for tyvars too, we
         look inside beta's kind.  And then reject the program
         becuase of the forall inside there.  But in fact that
         forall is fine -- it does not count as impredicative
         polymoprhism.   See Note [Checking for foralls]
         in TcType.
      3. All this fuss around occurrence checking forced me
         to look at TcUnify.checkTauTvUpdate
                and TcType.occurCheckExpand
         There's a lot of duplication there, and I managed
         to elminate quite a bit of it. For example,
         checkTauTvUpdate called a local 'defer_me'; and then
         called occurCheckExpand, which then used a very
         similar 'fast_check'.
         Things are better, but there is more to do.
      (cherry picked from commit 66a8c194)
    • Simon Peyton Jones's avatar
      Kill off redundant SigTv check in occurCheckExpand · 11f9bffb
      Simon Peyton Jones authored
      This patch simply deletes code, the SigTv check in
      occurCheckExpand.  As the new comment says
      In the past we also rejected a SigTv matched with a non-tyvar
      But it is wrong to reject that for Givens;
      and SigTv is in any case handled separately by
         - TcUnify.checkTauTvUpdate (on-the-fly unifier)
         - TcInteract.canSolveByUnification (main constraint solver)
      (cherry picked from commit d25cb61a)
    • Ryan Scott's avatar
      Disallow standalone deriving declarations involving unboxed tuples or sums · c448d551
      Ryan Scott authored
      There was an awful leak where GHC permitted standalone `deriving`
      declarations to create instances for unboxed sum or tuple types. This
      fortifies the checks that GHC performs to catch this scenario and give
      an appropriate error message.
      Fixes #11509.
      Test Plan: ./validate
      Reviewers: goldfire, austin, bgamari
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2557
      GHC Trac Issues: #11509
      (cherry picked from commit 23cf32da)
    • Simon Peyton Jones's avatar
      Print foralls in user format · 906ea044
      Simon Peyton Jones authored
      This fixes Trac #12597: in RnNames.warnMissingSignatures,
      use pprSigmaType not pprType
      (cherry picked from commit 796f0f2a)
    • Ömer Sinan Ağacan's avatar
      Fix layout of MultiWayIf expressions (#10807) · cb03d1cc
      Ömer Sinan Ağacan authored
      With this patch we stop generating virtual semicolons in MultiWayIf
      guards. Fixes #10807.
      Test Plan:
      Reviewers: simonmar, austin, bgamari
      Reviewed By: simonmar
      Subscribers: mpickering, thomie
      Differential Revision: https://phabricator.haskell.org/D2524
      GHC Trac Issues: #10807
      (cherry picked from commit c36904d6)
    • Simon Peyton Jones's avatar
      Fix desugaring of pattern bindings (again) · d2695b84
      Simon Peyton Jones authored
      This patch fixes Trac #12595.  The problem was with a
      pattern binding like
           !x = e
      For a start it's silly to match that pattern and build
      a unit tuple (the General Case of mkSelectorBinds); but
      that's what was happening because the bang fell through
      to the general case.  But for a variable pattern building
      any auxiliary bindings is stupid.  So the patch
      introduces a new case in mkSelectorBinds for variable
      Then it turned out that if 'e' was a plain variable, and
      moreover was imported GlobalId, then matchSinglePat made
      it a /bound/ variable, which should never happen.  That
      ultimately caused a linker error, but the original bug
      was much earlier.
      (cherry picked from commit 2fbfbca2)
    • Matthew Pickering's avatar
      Fix interaction of record pattern synonyms and record wildcards · 50e7157b
      Matthew Pickering authored
      We were missing an appropiate *ConLike lookup in the case when
      the pattern synonym was defined in a different module.
      Reviewers: austin, bgamari, simonpj
      Reviewed By: simonpj
      Subscribers: simonpj, thomie
      Differential Revision: https://phabricator.haskell.org/D2544
      GHC Trac Issues: #11987
      (cherry picked from commit 2d6642bd)
    • Adam Gundry's avatar
      Do not warn about unused underscore-prefixed fields (fixes Trac #12609) · 63ce9ba2
      Adam Gundry authored
      When DuplicateRecordFields is enabled, the mangling of selector names
      was causing them to be reported as unused even if prefixed by an
      underscore. This corrects the OccName used by the check.
      Test Plan: New test overloadedrecflds/should_compile/T12609
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2549
      GHC Trac Issues: #12609
      (cherry picked from commit 48ff0843)
    • Matthew Pickering's avatar
      Don't warn about name shadowing when renaming the patten in a PatSyn decl · 0c2b766d
      Matthew Pickering authored
      Previously the renamer assumed that *any* time we renamed a pattern, the
      pattern was introducing new binders. This isn't true in pattern synonym
      declarations where the pattern is used as part of a definition.
      We add a special case to not warn in this situation.
      Reviewers: simonpj, austin, bgamari
      Reviewed By: simonpj
      Subscribers: simonpj, thomie
      Differential Revision: https://phabricator.haskell.org/D2545
      GHC Trac Issues: #12615
      (cherry picked from commit 1851349a)
    • Peter Trommler's avatar
      PPC/CodeGen: fix lwa instruction generation · e7201e86
      Peter Trommler authored
      Opcode lwa is a 64-bit opcode and allows a DS-form only.  This patch
      generates lwa opcodes only when the offset is a multiple of 4.
      Fixes #12621
      Test Plan: validate
      Reviewers: erikd, hvr, simonmar, austin, bgamari
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2547
      GHC Trac Issues: #12621
      (cherry picked from commit ce3370e0)
    • Sylvain HENRY's avatar
      CodeGen X86: fix unsafe foreign calls wrt inlining · aec4a514
      Sylvain HENRY authored
      Foreign calls (unsafe and safe) interact badly with inlining and
      register passing ABIs (see #11792 and #12614):
      the inlined code to compute a parameter of the call may overwrite a
      register already set to pass a preceding parameter.
      With this patch, we compute all parameters which are not simple
      expressions before assigning them to fixed registers required by the
      Test Plan:
         - Add test (test both reg and stack parameters)
         - Validate
      Reviewers: osa1, bgamari, austin, simonmar
      Reviewed By: simonmar
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2263
      GHC Trac Issues: #11792, #12614
      (cherry picked from commit b61b7c24)