1. 02 Oct, 2016 12 commits
    • Ben Gamari's avatar
      Fix T12512 · 15df5170
      Ben Gamari authored
      15df5170
    • Simon Peyton Jones's avatar
      Fix a bug in occurs checking · 836f0e24
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      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
             TcType.swapOverVars
             TcType.canSolveByUnification
         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)
      836f0e24
    • Simon Peyton Jones's avatar
      Kill off redundant SigTv check in occurCheckExpand · 11f9bffb
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      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)
      11f9bffb
    • Ryan Scott's avatar
      Disallow standalone deriving declarations involving unboxed tuples or sums · c448d551
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      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)
      c448d551
    • Simon Peyton Jones's avatar
      Print foralls in user format · 906ea044
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      This fixes Trac #12597: in RnNames.warnMissingSignatures,
      use pprSigmaType not pprType
      
      (cherry picked from commit 796f0f2a)
      906ea044
    • Ömer Sinan Ağacan's avatar
      Fix layout of MultiWayIf expressions (#10807) · cb03d1cc
      Ömer Sinan Ağacan authored and Ben Gamari's avatar Ben Gamari committed
      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)
      cb03d1cc
    • Simon Peyton Jones's avatar
      Fix desugaring of pattern bindings (again) · d2695b84
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      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
      patterns.
      
      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)
      d2695b84
    • Matthew Pickering's avatar
      Fix interaction of record pattern synonyms and record wildcards · 50e7157b
      Matthew Pickering authored and Ben Gamari's avatar Ben Gamari committed
      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)
      50e7157b
    • Adam Gundry's avatar
      Do not warn about unused underscore-prefixed fields (fixes Trac #12609) · 63ce9ba2
      Adam Gundry authored and Ben Gamari's avatar Ben Gamari committed
      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)
      63ce9ba2
    • Matthew Pickering's avatar
      Don't warn about name shadowing when renaming the patten in a PatSyn decl · 0c2b766d
      Matthew Pickering authored and Ben Gamari's avatar Ben Gamari committed
      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)
      0c2b766d
    • Peter Trommler's avatar
      PPC/CodeGen: fix lwa instruction generation · e7201e86
      Peter Trommler authored and Ben Gamari's avatar Ben Gamari committed
      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)
      e7201e86
    • Sylvain HENRY's avatar
      CodeGen X86: fix unsafe foreign calls wrt inlining · aec4a514
      Sylvain HENRY authored and Ben Gamari's avatar Ben Gamari committed
      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
      ABI.
      
      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)
      aec4a514
  2. 27 Sep, 2016 1 commit
  3. 19 Sep, 2016 4 commits
    • Sergei Trofimovich's avatar
      configure.ac: fix --host= handling · b2050299
      Sergei Trofimovich authored and Ben Gamari's avatar Ben Gamari committed
      The following command fails as:
          $ ./configure --prefix=/usr \
              --build=x86_64-pc-linux-gnu \
              --host=x86_64-pc-linux-gnu \
              --target=x86_64-pc-linux-gnu
          configure: error:
          You've selected:
      
            BUILD:  x86_64-unknown-linux
            HOST:   x86_64-unknown-linux
            TARGET: x86_64-unknown-linux
      
          BUILD must equal HOST;
      
      18f06878
      
       changed native
      configure $build/$host/$target checks to ghc-mangled ones,
      but not completely.
      Signed-off-by: default avatarSergei Trofimovich <siarheit@google.com>
      
      Reviewers: rwbarton, erikd, austin, hvr, bgamari, Phyx
      
      Reviewed By: Phyx
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2508
      
      GHC Trac Issues: #12487
      
      (cherry picked from commit 0cc3931b)
      b2050299
    • Tamar Christina's avatar
      Fix configure detection. · 682518d4
      Tamar Christina authored and Ben Gamari's avatar Ben Gamari committed
      Summary:
      GHC's configure script seems to normalize the values returned from config.guess.
      So for Windows it turns x86_64-pc-mingw64 into x86_64-unknown-mingw32.
      These mangled names are stored in the values $BuildPlatform, $HostPlatform
      and $TargetPlatform.
      
      However further down the file when the comparison is done between the stage0
      compiler and the host the normalized versions are not used.
      So when normalization actually changes the triple this check will fail.
      
      Not sure why it's worked for all this time.. Nor if this is the right fix?
      Does it still work for cross compiling correctly?
      
      Test Plan: ./configure
      
      Reviewers: hvr, austin, thomie, bgamari, erikd
      
      Reviewed By: erikd
      
      Subscribers: erikd, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2452
      
      GHC Trac Issues: #12487
      
      (cherry picked from commit 18f06878)
      682518d4
    • Gabor Greif's avatar
      Trim all spaces after 'version:' · ec6526ea
      Gabor Greif authored and Ben Gamari's avatar Ben Gamari committed
      ... that we grep out of libraries/Cabal/Cabal/Cabal.cabal
      
      This is necessary because the file got reformatted
      in the 'master' branch.
      
      (cherry picked from commit 1101045c)
      ec6526ea
    • Simon Peyton Jones's avatar
      Fix scoping of type variables in instances · e134a5bc
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      This fixes Trac #12531:
      
         class Foo x where
           foo :: forall a . x a -> x a
           default foo :: forall b . x b -> x b
           foo x = go
             where go :: x b
                   go = undefined
      
      We want 'b' to scope over the code for 'foo', but we were
      using 'a' instead.
      
      (cherry picked from commit 0050aff2)
      e134a5bc
  4. 18 Sep, 2016 5 commits
  5. 16 Sep, 2016 1 commit
    • Ben Gamari's avatar
      Fix T12504 · 21c20203
      Ben Gamari authored
      This had an extra_files directive, which does not exist in ghc-8.0, from
      cherry-picking.
      21c20203
  6. 15 Sep, 2016 3 commits
    • Simon Peyton Jones's avatar
      Improve typechecking of instance defaults · 54b887b5
      Simon Peyton Jones authored and Ben Gamari's avatar Ben Gamari committed
      In an instance declaration when you don't specify the code for a
      method, GHC fills in from the default binding in the class.
      The type of the default method can legitmiately be ambiguous ---
      see Note [Default methods in instances] in TcInstDcls --- so
      typechecking it can be tricky.
      
      Trac #12220 showed that although we were dealing with that ambiguity
      for /vanilla/ default methods, we were not doing so for /generic/
      default methods.  Moreover we were dealing with it clumsily, by
      generating post-typechecked code.
      
      This patch fixes the bug AND deletes code!  We now use the same code
      path for both vanilla and generic default methods; and generate
      /pre-typechecked/ code in both cases.  The key trick is that we can use
      Visible Type Application to deal with the ambiguity, which wasn't
      possible before.  Hooray.
      
      There is a small hit to performance in compiler/perf/T1969 which
      consists of nothing BUT instance declarations with several default
      methods to fill, which we now have to typecheck. The actual hit is
      from 724 -> 756 or 4% in that extreme example.  Real world programs
      have vastly fewer instance decls.
      
      (cherry picked from commit d2958bd0)
      54b887b5
    • Simon Marlow's avatar
      Fix codegen bug in PIC version of genSwitch (#12433) · a0472f8d
      Simon Marlow authored and Ben Gamari's avatar Ben Gamari committed
      Summary:
      * getNonClobberedReg instead of getSomeReg, because the reg needs to
        survive across t_code
      * Use a new reg for the table offset calculation instead of clobbering
        the reg returned by expr (this was the bug affecting #12433)
      
      Test Plan: New unit test; validate
      
      Reviewers: rwbarton, bgamari, austin, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2529
      
      GHC Trac Issues: #12433
      a0472f8d
    • Ben Gamari's avatar
      Add failing testcase for #12433 · 094f3c69
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Test Plan: Validate
      
      Reviewers: austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2517
      
      GHC Trac Issues: #11433
      
      (cherry picked from commit dcc49044)
      094f3c69
  7. 12 Sep, 2016 5 commits
    • Ben Gamari's avatar
      rts: Disable -hb with multiple capabilities · c51caafa
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Biographical profiling is not thread-safe as documented in #12019. Throw
      an error when it is used in this way.
      
      Test Plan: Validate
      
      Reviewers: simonmar, austin, erikd
      
      Reviewed By: erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2516
      
      GHC Trac Issues: #12019
      
      (cherry picked from commit 6555c6bb)
      c51caafa
    • bitonic's avatar
      Make start address of `osReserveHeapMemory` tunable via command line -xb · 658f0354
      bitonic authored and Ben Gamari's avatar Ben Gamari committed
      Summary:
      We stumbled upon a case where an external library (OpenCL) does not work
      if a specific address (0x200000000) is taken.
      
      It so happens that `osReserveHeapMemory` starts trying to mmap at 0x200000000:
      
      ```
              void *hint = (void*)((W_)8 * (1 << 30) + attempt * BLOCK_SIZE);
              at = osTryReserveHeapMemory(*len, hint);
      ```
      
      This makes it impossible to use Haskell programs compiled with GHC 8
      with C functions that use OpenCL.
      
      See this example ​https://github.com/chpatrick/oclwtf for a repro.
      
      This patch allows the user to work around this kind of behavior outside
      our control by letting the user override the starting address through an
      RTS command line flag.
      
      Reviewers: bgamari, Phyx, simonmar, erikd, austin
      
      Reviewed By: Phyx, simonmar
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2513
      
      (cherry picked from commit 1b5f9207)
      658f0354
    • Ryan Scott's avatar
      Fix TH ppr output for list comprehensions with only one Stmt · 43149ea6
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      A folow-up to D2521 (which addressed #12583), where the `Outputable` `ppr`
      output was tweaked to display a list comprehension with only one `Stmt` as
      `[Foo]` instead of `[Foo|]` (which isn't valid Haskell). I forgot to update
      the corresponding code in `Language.Haskell.TH.Ppr` which pretty-prints
      `CompE`, however, so this commit takes care of that.
      
      (cherry picked from commit 0e7ccf6d)
      43149ea6
    • Ryan Scott's avatar
      Fix derived Ix instances for one-constructor GADTs · 706a7305
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      Standalone-derived `Ix` instances would panic on GADTs with exactly
      one constructor, since the list of fields was being passed to a function that
      uses `foldl1` in order to generate an implementation for `inRange`. This adds a
      simple check that makes `inRange` be `True` whenever a product type has no
      fields.
      
      Fixes #12583.
      
      Test Plan: make test TEST=12583
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2521
      
      GHC Trac Issues: #12583
      
      (cherry picked from commit 7b7ea8f4)
      706a7305
    • Edward Z. Yang's avatar
      Update unix submodule to latest HEAD. · 96850ef9
      Edward Z. Yang authored and Ben Gamari's avatar Ben Gamari committed
      
      
      Fixes readdir validation error (fixes #12572).
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      (cherry picked from commit a8238a4e)
      96850ef9
  8. 10 Sep, 2016 1 commit
    • Tamar Christina's avatar
      Add platform warning to Foreign.C.Types · 14fb8ef3
      Tamar Christina authored and Ben Gamari's avatar Ben Gamari committed
      Summary:
      The generated documentation for thhe Foreign.C.Types
      module is generated based on the platform which ran Haddock.
      
      This is generating incorrect types for e.g. Windows.
      
      Add a disclaimer to the top of the page to ask people to
      keep this in mind.
      
      Test Plan: make documentation and inspect Haddock
      
      Reviewers: erikd, austin, hvr, bgamari
      
      Reviewed By: erikd
      
      Subscribers: RyanGlScott, #ghc_windows_task_force, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2523
      
      GHC Trac Issues: #12586
      
      (cherry picked from commit 710f21cc)
      14fb8ef3
  9. 09 Sep, 2016 4 commits
  10. 08 Sep, 2016 1 commit
  11. 05 Sep, 2016 3 commits
    • Erik de Castro Lopo's avatar
      Fix GHCi perf-llvm build on x86_64 · 676efb9f
      Erik de Castro Lopo authored and Ben Gamari's avatar Ben Gamari committed
      With BuildFlavour set to `perf-llvm`, GHCi would fail as soon as it
      was run with:
      
        ghc-stage2: .../ghc-prim/dist-install/build/HSghc-prim-0.5.0.0.o:
        unknown symbol `__udivti3'
        ghc-stage2: unable to load package `ghc-prim-0.5.0.0'
      
      Fix this by adding `__udivti3` and `__umodti3` to RtsSymbols.c.
      
      Test Plan: Validate
      
      Reviewers: simonmar, austin, bgamari, Phyx, trofi
      
      Reviewed By: Phyx, trofi
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2449
      
      GHC Trac Issues: #11981
      
      (cherry picked from commit bd0c3106)
      676efb9f
    • Ben Gamari's avatar
      InstEnv: Ensure that instance visibility check is lazy · 291b439f
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Previously instIsVisible had completely broken the laziness of
      lookupInstEnv' since it would examine is_dfun_name to check the name of
      the defining module (to know whether it is an interactive module). This
      resulted in the visibility check drawing in an interface file
      unnecessarily. This contributed to the unnecessary regression in
      compiler allocations reported in #12367.
      
      Test Plan: Validate, check nofib changes
      
      Reviewers: simonpj, ezyang, austin
      
      Reviewed By: ezyang
      
      Subscribers: thomie, ezyang
      
      Differential Revision: https://phabricator.haskell.org/D2411
      
      GHC Trac Issues: #12367
      
      (cherry picked from commit ed480981)
      291b439f
    • Iavor S. Diatchki's avatar
      Be more aggressive when checking constraints for custom type errors. · 23be8c99
      Iavor S. Diatchki authored and Ben Gamari's avatar Ben Gamari committed
      This fixes #11990.
      
      The current rule is simpler than before: if we encounter an unsolved
      constraint that contains any mentions of properly applied `TypeError`,
      then we report the type error.
      
      If there are multiple `TypeErrors`, then we just report one of them.
      
      Reviewers: simonpj, bgamari, austin
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2151
      
      GHC Trac Issues: #11990
      
      (cherry picked from commit b75d1940)
      23be8c99