1. 27 Jan, 2016 10 commits
    • niteria's avatar
      Rename "open" subst functions · 5dcae88b
      niteria authored
      This is the renaming that @simonpj requested:
      ```
      · zipOpenTCvSubst  -> zipTvSubst   (It only deals with tyvars)
      
      · zipOpenTCvSubstCoVars -> zipCvSubst   (it only deals with
      covars)
      
      · zipOpenTCvSubstBinders ->  zipTyBinderSubst  (it only deals
      with TyBinders, not covars)
      ```
      plus the `mk` variant.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, goldfire, austin, bgamari
      
      Subscribers: thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D1853
      
      GHC Trac Issues: #11371
      5dcae88b
    • eir@cis.upenn.edu's avatar
      Refactor the typechecker to use ExpTypes. · 00cbbab3
      eir@cis.upenn.edu authored
      The idea here is described in [wiki:Typechecker]. Briefly,
      this refactor keeps solid track of "synthesis" mode vs
      "checking" in GHC's bidirectional type-checking algorithm.
      When in synthesis mode, the expected type is just an IORef
      to write to.
      
      In addition, this patch does a significant reworking of
      RebindableSyntax, allowing much more freedom in the types
      of the rebindable operators. For example, we can now have
      `negate :: Int -> Bool` and
      `(>>=) :: m a -> (forall x. a x -> m b) -> m b`. The magic
      is in tcSyntaxOp.
      
      This addresses tickets #11397, #11452, and #11458.
      
      Tests:
        typecheck/should_compile/{RebindHR,RebindNegate,T11397,T11458}
        th/T11452
      00cbbab3
    • eir@cis.upenn.edu's avatar
      Fix some substitution InScopeSets · 2899aa58
      eir@cis.upenn.edu authored
      This is relevant to #11371.
      2899aa58
    • Ömer Sinan Ağacan's avatar
      s/unLifted/unlifted for consistency · 4faa1a63
      Ömer Sinan Ağacan authored
      This was causing trouble as we had to remember when to use "unLifted"
      and when to use "unlifted".
      
      "unlifted" is used instead of "unLifted" as it's a single word.
      
      Reviewers: austin, hvr, goldfire, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1852
      4faa1a63
    • rwbarton's avatar
      Test for undef bugs in the LLVM backend when validating · d50609e8
      rwbarton authored
      In an attempt to catch bugs involving using undef values, replace
      undef literals by values likely to cause crashes or test failures.
      We do this only when validating since it is a deoptimization.
      
      This depends on D1857 to catch such bugs in the RTS (such as #11487).
      
      Test Plan:
      Did a build with
      ```
      BuildFlavour = quick-llvm
      SRC_HC_OPTS_STAGE1 = -fllvm-fill-undef-with-garbage
      ```
      The build crashed when running ghc-stage2, as expected.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1858
      d50609e8
    • olsner's avatar
      Restore original alignment for info tables · 0dc7b36c
      olsner authored
      This was broken in 4a32bf92, meaning
      that info tables and subsequent code are no longer guaranteed to have
      the recommended alignment.  Split up the section header and section
      alignment printers, and print an appropriate alignment directive before
      each info table.
      
      Fixes Trac #11486
      
      Reviewers: austin, bgamari, rwbarton
      
      Reviewed By: bgamari, rwbarton
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1847
      
      GHC Trac Issues: #11486
      0dc7b36c
    • triple's avatar
      ghci: fix trac issue #11481 · 1f6d1422
      triple authored
      Test Plan: validate
      
      Reviewers: thomie, austin, bgamari
      
      Reviewed By: bgamari
      
      Differential Revision: https://phabricator.haskell.org/D1833
      
      GHC Trac Issues: #11481
      1f6d1422
    • Gabor Greif's avatar
      Typos in comments · 448ea978
      Gabor Greif authored
      448ea978
    • niteria's avatar
      Fix a typo in the note name in comments · 45fd83bb
      niteria authored
      This is `subsititution` to `substitution`, plus one instance of
      the note that I missed.
      
      Test Plan: docufix
      
      Reviewers: simonpj, bgamari, austin, goldfire
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1856
      
      GHC Trac Issues: #11371
      45fd83bb
    • Tamar Christina's avatar
      Enable RemoteGHCi on Windows · 44a5d51a
      Tamar Christina authored
      Makes the needed changes to make RemoteGHCi work on Windows.
      The approach passes OS Handles areound instead of the Posix Fd
      as on Linux.
      
      The reason is that I could not find any real documentation about
      the behaviour of Windows w.r.t inheritance and Posix FDs.
      
      The implementation with Fd did not seem to be able to find the Fd
      in the child process. Instead I'm using the much better documented
      approach of passing inheriting handles.
      
      This requires a small modification to the `process` library.
      https://github.com/haskell/process/pull/52
      
      Test Plan: ./validate On Windows x86_64
      
      Reviewers: thomie, erikd, bgamari, simonmar, austin, hvr
      
      Reviewed By: simonmar
      
      Subscribers: #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D1836
      
      GHC Trac Issues: #11100
      44a5d51a
  2. 26 Jan, 2016 7 commits
    • niteria's avatar
      Construct in_scope set in mkTopTCvSubst · 144ddb41
      niteria authored
      The pre-condition on `mkTopTCvSubst` turned out to be wrong and
      not satisfied by any of the callers. I've fixed it, so that it
      constructs the in_scope set from the range of the substitution.
      `mkTopTCvSubst` was also unnecessarily general it is never called
      with `CoVars`, so I changed the type signature and added an assertion.
      
      Test Plan: ./validate --slow
      
      Reviewers: goldfire, simonpj, bgamari, austin
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1801
      
      GHC Trac Issues: #11371
      144ddb41
    • Ryan Scott's avatar
      Split off -Wunused-type-variables from -Wunused-matches · 6817703b
      Ryan Scott authored
      Summary:
      Previously, `-Wunused-matches` would fire whenever it detected unused type
      variables in a type family or data family instance. This can be annoying for
      users who wish to use type variable names as documentation, as being
      `-Wall`-compliant would mean that they'd have to prefix many of their type
      variable names with underscores, making the documentation harder to read.
      
      To avoid this, a new warning `-Wunused-type-variables` was created that only
      encompasses unused variables in family instances. `-Wunused-matches` reverts
      back to its role of only warning on unused term-level pattern names. Unlike
      `-Wunused-matches`, `-Wunused-type-variables` is not implied by `-Wall`.
      
      Fixes #11451.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, ekmett, austin, hvr, simonpj, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1825
      
      GHC Trac Issues: #11451
      6817703b
    • niteria's avatar
      Pass InScopeSet to substTy in lintTyApp · 01809bcd
      niteria authored
      This is the fix proposed in #11371:
      ```
      In other cases, we already have the in-scope set in hand. Example: in
      CoreLint.lintTyApp we find a call to substTyWith. But Lint carries an
      in-scope set, so it would be easy to pass it to substTyWith.
      ```
      
      Test Plan: ./validate --slow (only pre-existing problems)
      
      Reviewers: simonpj, goldfire, austin, nomeata, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1820
      
      GHC Trac Issues: #11371
      01809bcd
    • Simon Peyton Jones's avatar
      Fix two cloning-related bugs · 016a0bd1
      Simon Peyton Jones authored
      Crikey!  Not just one but two bugs in type variable cloning,
      both dating from the days before PolyKinds.  Both were shown up
      by Trac #11330.
      
      1. In SetLevels, when floating a case expression we must clone its
         binders, *and* do so in a telescope-aware way, because the
         constructor may bind a kind variable that appears in the kind
         of a type variable.
      
         Instead of doing this (wrongly) by steam, call CoreSubst.cloneBndrs.
      
         I added Notes and did other refactoring at the same time.
      
      2. It turned out that CoreSubst.cloneBndrs calls TyCoRep.cloneTyVarBndr,
         and that too was bogus!  It didn't substitute in the kind of the
         TyVar being cloned.  There was even a comment to say "variables can't
         appear in kinds".  Thta hasn't been true for a long time now.
      
      Easily fixed.
      
      Interestingly, I then found that test
         dependent/should_compile/KindEqualities
      was emitting a new inexhaustive-pattern-match warning.  Sure enough
      it was valid!  So the lack of cloning in cloneTyVarBndr really was
      causing an observable bug; just one that we had not observed.
      016a0bd1
    • Simon Peyton Jones's avatar
      Kill off zipTopTCvSubst in favour of zipOpenTCvSubst · 1c6d70c2
      Simon Peyton Jones authored
      As Bartosz has discovered, the invariants for substitutions were
      wrong, and in particular the "mkTop...Subst" and "zipTop..Subst"
      functions were building substitutions that didn't obey even the
      old invariants.
      
      This patch kills of the bogus zipTopTCvSubst in favour of the
      more robust zipOpenTCvSubst.
      
      I tripped over this because my upcoming patch (concerning SetLevels,
      Trac #11330) triggered an ASSERT failure in the substitution
      well-formedness assertion in TyCoRep.
      1c6d70c2
    • Simon Peyton Jones's avatar
      White space only · cf788a53
      Simon Peyton Jones authored
      cf788a53
    • Simon Peyton Jones's avatar
      Less verbose output for the in-scope set · 632f020b
      Simon Peyton Jones authored
      With -dppr-debug the output for the (ofen-large) InScope set
      was overwhelming.  This makes it smaller.
      
      Only affects debugging.
      632f020b
  3. 25 Jan, 2016 8 commits
    • Ben Gamari's avatar
      Implement -Wunrecognised-warning-flag · f0f63b39
      Ben Gamari authored
      This allows the user to avoid warnings for warning flags that GHC
      doesn't recognise. See #11429 for details..
      
      Test Plan: Validate with T11429[abc] tests
      
      Reviewers: austin, hvr
      
      Reviewed By: hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1830
      
      GHC Trac Issues: #11429
      f0f63b39
    • Herbert Valerio Riedel's avatar
      Rename -Wmissing-monadfail-instance to plural-form · 132c2089
      Herbert Valerio Riedel authored
      This warning flag was recently introduced as part of #10751. However,
      it was missed during code-review that almost all existing warning
      flags use a plural-form, so for consistency this commit renames
      that warning flag to `-Wmissing-monadfail-instances`.
      
      Test Plan: local validate (still running)
      
      Reviewers: quchen, goldfire, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1842
      
      GHC Trac Issues: #10751
      132c2089
    • Ben Gamari's avatar
      HscTypes: Fix typo in comment · bc1e085c
      Ben Gamari authored
      bc1e085c
    • Simon Peyton Jones's avatar
      Fix exprIsHNF (Trac #11248) · 3c060f36
      Simon Peyton Jones authored
      Blimey!  CoreUtils.exprIsHNFlike had not one but two bugs.
      
       * is_hnf_like treated coercion args like type args
         (result: exprIsHNF might wrongly say True)
      
       * app_is_value treated type args like value args
         (result: exprIsHNF might wrongly say False)
      
      Bizarre.  This goes back to at least 2012. It's amazing that it
      hasn't caused more trouble.
      
      It was discovered by a Lint error when compiling Trac #11248 with -O.
      3c060f36
    • Simon Peyton Jones's avatar
      Improve tracing in checkValidInstance · f7e0e5f9
      Simon Peyton Jones authored
      f7e0e5f9
    • Simon Peyton Jones's avatar
      Avoid recursive use of immSuperClasses · 42c6263f
      Simon Peyton Jones authored
      In fixing Trac #11480 I had omitted to deal with FunDeps.oclose,
      which was making recursive use of immSuperClasses, and hence
      going into a loop in the recursive case.
      
      Solution: use transSuperClasses, which takes care not to.
      42c6263f
    • Simon Peyton Jones's avatar
      Refactor validity checking for type/data instances · 746764cc
      Simon Peyton Jones authored
      I found that there was some code duplication going on,
      so I've put more into the shared function checkValidFamPats.
      
      I did some refactoring in checkConsistentFamInst too,
      preparatory to #11450; the error messages change a little
      but no change in behaviour.
      746764cc
    • Simon Peyton Jones's avatar
      Special-case implicit params in superclass expansion · ff21795a
      Simon Peyton Jones authored
      This issue came up in Trac #11480, and is documented in
      Note [When superclasses help] in TcRnTypes.
      
      We were getting a spurious warning
        T11480.hs:1:1: warning:
           solveWanteds: too many iterations (limit = 4)
      
      The fix is easy.  A bit of refactoring along the way.
      
      The original bug report in Trac #11480 appears to work
      fine in HEAD and the 8.0 branch but I added a regression
      test in this commit as well.
      ff21795a
  4. 24 Jan, 2016 2 commits
    • Herbert Valerio Riedel's avatar
      Implement `-Wnoncanonical-monadfail-instances` warning · fd6dd41c
      Herbert Valerio Riedel authored
      The MonadFail proposal implemented so far via #10751 only warns about
      missing `MonadFail` instances based on existence of failible pattern
      matches in `do`-blocks.
      
      However, based on the noncanonical Monad warnings implemented via #11150
      we can provide a different mechanism for detecting missing `MonadFail`
      instances quite cheaply. That is, by checking for canonical `fail` definitions.
      
      In the case of `Monad`/`MonadFail`, we define the canonical implementation of
      `fail` to be such that the soft-deprecated method shall (iff overridden) be
      defined in terms of the non-deprecated method. Consequently, in case of
      `MonadFail`, the `Monad(fail)` method shall be defined as alias of
      the `MonadFail(fail)` method.
      
      This allows us at some distant point in the future to remove `fail` from
      the `Monad` class, while having GHC ignore/tolerate such literal canonical
      method definitions.
      
      Reviewed By: bgamari, RyanGlScott
      
      Differential Revision: https://phabricator.haskell.org/D1838
      fd6dd41c
    • thomie's avatar
      Remove `replaceDynFlags` from `ContainsDynFlags` · edc68b2f
      thomie authored
      Refactoring only. It's shorter, and brings
      `HasDynFlags/ContainsDynFLags` in line with `HasModule/ContainsModule`.
      Introduce `updTopEnv`.
      
      Reviewed by: bgamari
      
      Differential Revision: https://phabricator.haskell.org/D1832
      edc68b2f
  5. 23 Jan, 2016 3 commits
  6. 22 Jan, 2016 2 commits
    • Jonas Scholl's avatar
      Do not count void arguments when considering a function for loopification. · 4d51bfc8
      Jonas Scholl authored
      This fixes #11372 by omitting arguments with a void-type when checking
      whether a self-recursive tail call can be optimized to a local jump.
      Previously, a function taking a real argument and a State# token
      would report an arity of 1 in the SelfLoopInfo in getCallMethod,
      but a self-recursive call would apply it to 2 arguments, one of them
      being the State# token, thus no local jump would be generated.
      As the State# token is not represented by anything at runtime, we can
      ignore it and thus trigger the loopification optimization.
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: simonmar, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1767
      
      GHC Trac Issues: #11372
      4d51bfc8
    • Eric Seidel's avatar
      Default non-canonical CallStack constraints · 835a2a24
      Eric Seidel authored
      Test Plan: `make test TEST=T11462`
      
      Reviewers: austin, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1804
      
      GHC Trac Issues: #11462
      835a2a24
  7. 21 Jan, 2016 8 commits