1. 06 Jul, 2018 2 commits
    • Michael Sloan's avatar
      Add a broken test for lingering state from TH unique names #9693 · fbe162f5
      Michael Sloan authored
      The stderr output is
      
      ```
      Loading with T9693_initial.hs
      
      T9693_main.hs:4:1:
          Same exact name in multiple name-spaces:
            type constructor or class ‘X’, declared at: T9693_main.hs:4:1
            data constructor ‘X’, declared at: T9693_main.hs:4:1
            Probable cause: you bound a unique Template Haskell name (NameU),
            perhaps via newName, in different name-spaces.
            If that's it, then -ddump-splices might be useful
      Reloading with T9693_modified.hs
      
      T9693_main.hs:1:1:
          Data constructor ‘X’ used as a type constructor
      ```
      
      The strange thing is that the modified version uses (mkName "X"), which should
      be fine for simultaneous use in both a data constructor and type constructor.
      Indeed, on a fresh load, the modified version works fine. So there is some sort
      of state left over from the prior load when (newName "X") was used.
      
      Test Plan: testsuite/tests/th/T9693.script
      
      Reviewers: bgamari, sighingnow, RyanGlScott
      
      Reviewed By: sighingnow, RyanGlScott
      
      Subscribers: RyanGlScott, sighingnow, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4926
      fbe162f5
    • Krzysztof Gogolewski's avatar
      Mark AutoDeriveTypeable as deprecated · f59332f9
      Krzysztof Gogolewski authored
      Test Plan: validate
      
      Reviewers: bgamari, alpmestan
      
      Reviewed By: alpmestan
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15342
      
      Differential Revision: https://phabricator.haskell.org/D4933
      f59332f9
  2. 05 Jul, 2018 9 commits
    • Ryan Scott's avatar
      Accept new stdout for tcrun045 · 45f00268
      Ryan Scott authored
      The stdout produced by test tcrun045 changed in commit
      45f44e2c. The change appears to be
      benign, so I've decided to accept it.
      45f00268
    • Ryan Scott's avatar
      Make ppr_tc_args aware of -fprint-explicit-kinds · dbdcacfc
      Ryan Scott authored
      Summary:
      `ppr_tc_args` was printing invisible kind arguments even
      when `-fprint-explicit-kinds` wasn't enabled. Easily fixed.
      
      Test Plan: make test TEST=T15341
      
      Reviewers: goldfire, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #15341
      
      Differential Revision: https://phabricator.haskell.org/D4932
      dbdcacfc
    • Ryan Scott's avatar
      Fix #15331 with careful blasts of parenthesizeHsType · b6a33861
      Ryan Scott authored
      Summary:
      Another `-ddump-splices` bug that can be solved with more
      judicious use of parentheses.
      
      Test Plan: make test TEST=T15331
      
      Reviewers: goldfire, bgamari, alanz, tdammers
      
      Reviewed By: tdammers
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15331
      
      Differential Revision: https://phabricator.haskell.org/D4920
      b6a33861
    • Ryan Scott's avatar
      Parenthesize rank-n contexts in Convert · 57733978
      Ryan Scott authored
      Summary: A simple oversight.
      
      Test Plan: make test TEST=T15324
      
      Reviewers: goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15324
      
      Differential Revision: https://phabricator.haskell.org/D4910
      57733978
    • Ryan Scott's avatar
      Fix newtype instance GADTs · 92751866
      Ryan Scott authored
      Summary: This was taken from Richard's branch, which in turn was
      submitted to Phab by Matthew, which in turn was commandeered by Ryan.
      
      This fixes an issue with newtype instances in which too many
      coercions were being applied in the worker. This fixes the issue by
      removing the data family instance axiom from the worker and moving
      to the wrapper. Moreover, we now require all newtype instances
      to have wrappers, for symmetry with data instances.
      
      Reviewers: goldfire, bgamari, simonpj, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #15318
      
      Differential Revision: https://phabricator.haskell.org/D4902
      92751866
    • Ryan Scott's avatar
      Instantiate GND bindings with an explicit type signature · 132273f3
      Ryan Scott authored
      Summary:
      Before, we were using visible type application to apply
      impredicative types to `coerce` in
      `GeneralizedNewtypeDeriving`-generated bindings. This approach breaks
      down when combined with `QuantifiedConstraints` in certain ways,
      which #14883 and #15290 provide examples of. See
      Note [GND and QuantifiedConstraints] for all the gory details.
      
      To avoid this issue, we instead use an explicit type signature to
      instantiate each GND binding, and use that to bind any type variables
      that might be bound by a class method's type signature. This reduces
      the need to impredicative type applications, and more importantly,
      makes the programs from #14883 and #15290 work again.
      
      Test Plan: make test TEST="T15290b T15290c T15290d T14883"
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14883, #15290
      
      Differential Revision: https://phabricator.haskell.org/D4895
      132273f3
    • Ryan Scott's avatar
      Fix #15308 by suppressing invisble args more rigorously · 93b7ac8d
      Ryan Scott authored
      Summary:
      There was a buglet in `stripInvisArgs` (which is part of the
      pretty-printing pipeline for types) in which only invisble arguments
      which came before any visible arguments would be suppressed, but any
      invisble arguments that came //after// visible ones would still be
      printed, even if `-fprint-explicit-kinds`  wasn't enabled.
      The fix is simple: make `stripInvisArgs` recursively process the
      remaining types even after a visible argument is encountered.
      
      Test Plan: make test TEST=T15308
      
      Reviewers: goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #15308
      
      Differential Revision: https://phabricator.haskell.org/D4891
      93b7ac8d
    • Ryan Scott's avatar
      Fix #15307 by making nlHsFunTy parenthesize more · 59a15a56
      Ryan Scott authored
      Summary:
      `nlHsFunTy` wasn't parenthesizing its arguments at all,
      which led to `-ddump-deriv` producing incorrectly parenthesized
      types (since it uses `nlHsFunTy` to construct those types), as
      demonstrated in #15307. Fix this by changing `nlHsFunTy` to add
      parentheses à la `ppr_ty`: always parenthesizing the argument type
      with function precedence, and recursively processing the result type,
      adding parentheses for each function type it encounters.
      
      Test Plan: make test TEST=T14578
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15307
      
      Differential Revision: https://phabricator.haskell.org/D4890
      59a15a56
    • Simon Peyton Jones's avatar
      Refactor validity checking for constraints · 45f44e2c
      Simon Peyton Jones authored
      There are several changes here.
      
      * TcInteract has gotten too big, so I moved all the class-instance
        matching out of TcInteract into a new module ClsInst. It parallels
        the FamInst module.
      
        The main export of ClsInst is matchGlobalInst.
        This now works in TcM not TcS.
      
      * A big reason to make matchGlobalInst work in TcM is that we can
        then use it from TcValidity.checkSimplifiableClassConstraint.
        That extends checkSimplifiableClassConstraint to work uniformly
        for built-in instances, which means that we now get a warning
        if we have givens (Typeable x, KnownNat n); see Trac #15322.
      
      * This change also made me refactor LookupInstResult, in particular
        by adding the InstanceWhat field.  I also changed the name of the
        type to ClsInstResult.
      
        Then instead of matchGlobalInst reporting a staging error (which is
        inappropriate for the call from TcValidity), we can do so in
        TcInteract.checkInstanceOK.
      
      * In TcValidity, we now check quantified constraints for termination.
        For example, this signature should be rejected:
           f :: (forall a. Eq (m a) => Eq (m a)) => blah
        as discussed in Trac #15316.   The main change here is that
        TcValidity.check_pred_help now uses classifyPredType, and has a
        case for ForAllPred which it didn't before.
      
        This had knock-on refactoring effects in TcValidity.
      45f44e2c
  3. 04 Jul, 2018 3 commits
  4. 01 Jul, 2018 1 commit
  5. 29 Jun, 2018 2 commits
  6. 26 Jun, 2018 2 commits
    • Simon Peyton Jones's avatar
      Fix TcLevel manipulation in TcDerivInfer.simplifyDeriv · 261dd83c
      Simon Peyton Jones authored
      The level numbers we were getting simply didn't obey the
      invariant (ImplicInv) in TcType
         Note [TcLevel and untouchable type variables]
      
      That leads to chaos. Easy to fix.  I improved the documentation.
      
      I also added an assertion in TcSimplify that checks that
      level numbers go up by 1 as we dive inside implications, so
      that we catch the problem at source rather than than through
      its obscure consequences.
      
      That in turn showed up that TcRules was also generating
      constraints that didn't obey (ImplicInv), so I fixed that too.
      I have no idea what consequences were lurking behing that
      bug, but anyway now it's fixed.  Hooray.
      261dd83c
    • Alan Zimmerman's avatar
      API Annotations when parsing typapp · e53c113d
      Alan Zimmerman authored
      Make sure the original annotations are still accessible for a promoted
      type.
      
      Closes #15303
      e53c113d
  7. 25 Jun, 2018 1 commit
    • Simon Peyton Jones's avatar
      Fix error recovery for pattern synonyms · 2896082e
      Simon Peyton Jones authored
      As Trac #15289 showed, we were carrying on after a type error
      in a pattern synonym, and then crashing.  This patch improves
      error handling for pattern synonyms.
      
      I also moved a bit of code from TcBinds into TcPatSyn, which
      helpfully narrows the API.
      2896082e
  8. 24 Jun, 2018 1 commit
  9. 22 Jun, 2018 1 commit
    • Simon Peyton Jones's avatar
      Instances in no-evidence implications · 32eb4199
      Simon Peyton Jones authored
      Trac #15290 showed that it's possible that we might attempt to use a
      quantified constraint to solve an equality in a situation where we
      don't have anywhere to put the evidence bindings.  This made GHC crash.
      
      This patch stops the crash, but still rejects the pogram.  See
      Note [Instances in no-evidence implications] in TcInteract.
      
      Finding this bug revealed another lurking bug:
      
      * An infelicity in the treatment of superclasses -- we were expanding
        them locally at the leaves, rather than at their binding site; see
        (3a) in Note [The superclass story].
      
        As a consequence, TcRnTypes.superclassesMightHelp must look inside
        implications.
      
      In more detail:
      
      * Stop the crash, by making TcInteract.chooseInstance test for
        the no-evidence-bindings case.  In that case we simply don't
        use the instance.  This entailed a slight change to the type
        of chooseInstance.
      
      * Make TcSMonad.getPendingScDicts (now renamed getPendingGivenScs)
        return only Givens from the /current level/; and make
        TcRnTypes.superClassesMightHelp look inside implications.
      
      * Refactor the simpl_loop and superclass-expansion stuff in
        TcSimplify.  The logic is much easier to understand now, and
        has less duplication.
      32eb4199
  10. 20 Jun, 2018 7 commits
  11. 19 Jun, 2018 4 commits
  12. 18 Jun, 2018 3 commits
    • Gabor Greif's avatar
      Typofixes in docs and comments [ci skip] · 6ac8a72f
      Gabor Greif authored
      6ac8a72f
    • Simon Peyton Jones's avatar
      Fix typechecking of kind signatures · 30b029be
      Simon Peyton Jones authored
      When typechecking a type like
         Maybe (a :: <kind-sig>)
      with a kind signature, we were using tc_lhs_kind to
      typecheck the signature.  But that's utterly wrong; we
      need the signature to be fully solid (non unresolved
      equalities) before using it.  In the case of Trac #14904
      we went on to instantiate the kind signature, when it
      still had embedded unsolved constraints.  This tripped
      the level-checking assertion when unifying a variable.
      
      The fix looks pretty easy to me: just call tcLHsKind
      instead.  I had to add KindSigCtxt to
      30b029be
    • Simon Peyton Jones's avatar
      Fix an infinite loop in niFixTCvSubst · d6216443
      Simon Peyton Jones authored
      Trac #14164 made GHC loop, a pretty serious error. It turned
      out that Unify.niFixTCvSubst was looping forever, because we
      had a substitution like
          a :-> ....(b :: (c :: d))....
          d :-> ...
      We correctly recognised that d was free in the range of the
      substitution, but then failed to apply it "deeeply enough"
      to the range of the substiuttion, so d was /still/ free in
      the range, and we kept on going.
      
      Trac #9106 was caused by a similar problem, but alas my
      fix to Trac #9106 was inadequate when the offending type
      variable is more deeply buried.  Urk.
      
      This time I think I've fixed it!  It's much more subtle
      than I though, and it took most of a long train journey
      to figure it out.  I wrote a long note to explain:
      Note [Finding the substitution fixpoint]
      d6216443
  13. 17 Jun, 2018 4 commits
    • Ryan Scott's avatar
      Remove accidentally checked-in T14845.stderr · 50d7b2ac
      Ryan Scott authored
      This was a stderr file for a WIP test in D4728. I ended up removing
      the test, but forgot to remove the stderr file.
      50d7b2ac
    • Ryan Scott's avatar
      Provide a better error message for unpromotable data constructor contexts · c6375411
      Ryan Scott authored
      Trac #14845 brought to light a corner case where a data
      constructor could not be promoted (even with `-XTypeInType`) due to
      an unpromotable constraint in its context. However, the error message
      was less than helpful, so this patch adds an additional check to
      `tcTyVar` catch unpromotable data constructors like these //before//
      they're promoted, and to give a sensible error message in such cases.
      
      Test Plan: make test TEST="T13895 T14845"
      
      Reviewers: simonpj, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #13895, #14845
      
      Differential Revision: https://phabricator.haskell.org/D4728
      c6375411
    • sgillespie's avatar
      Improve error message when importing an unusable package · df0f148f
      sgillespie authored
      If a module cannot be found because it is ignored or from an unusable
      package, report this to the user and the reason it is unusable.
      
      Currently, GHC displays the standard "Cannot find module error". For
      example:
      
      ```
      <no location info>: error:
          Could not find module ‘Control.Monad.Random’
          Perhaps you meant
            Control.Monad.Reader (from mtl-2.2.2)
            Control.Monad.Cont (from mtl-2.2.2)
            Control.Monad.Error (from mtl-2.2.2)
      ```
      
      GHC does, however, indicate unusable/ignored packages with the -v flag:
      
      ```
      package MonadRandom-0.5.1-1421RgpXdhC8e8UI7D3emA is unusable due to
      missing dependencies:
        fail-4.9.0.0-BAHmj60kS5K7NVhhKpm9J5
      ```
      
      With this change, I took that message and added it to the output of the
      "Cannot find module" message.
      
      Reviewers: bgamari, dfeuer
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, dfeuer, rwbarton, thomie, carter
      
      GHC Trac Issues: #4806
      
      Differential Revision: https://phabricator.haskell.org/D4783
      df0f148f
    • Adam Gundry's avatar
      Handle DuplicateRecordFields correctly in filterImports (fixes #14487) · ccd8ce40
      Adam Gundry authored
      filterImports needed a small adjustment to correctly handle record field
      definitions arising from modules with DuplicateRecordFields enabled.
      
      Previously hiding fields was not possible with DuplicateRecordFields enabled.
      
      Test Plan: new test rename/should_compile/T14487
      
      Reviewers: bgamari
      
      Subscribers: simonpj, rwbarton, thomie, carter
      
      GHC Trac Issues: #14487
      
      Differential Revision: https://phabricator.haskell.org/D4805
      ccd8ce40