1. 14 Oct, 2016 2 commits
    • Ryan Scott's avatar
      Make error when deriving an instance for a typeclass less misleading · d5a4e49d
      Ryan Scott authored
      Before, when you attempted to derive an instance for a typeclass,
      e.g.,
      
      ```
      class C1 (a :: Constraint) where
      class C2 where
      
      deriving instance C1 C2
      ```
      
      GHC would complain that `C2`'s data constructors aren't in scope. But
      that
      makes no sense, since typeclasses don't have constructors! By refining
      the
      checks that GHC performs when deriving, we can make the error message a
      little more sensible.
      
      This also cleans up a related `DeriveAnyClass` infelicity. Before, you
      wouldn't have been able to compile code like this:
      
      ```
      import System.IO (Handle)
      class C a
      deriving instance C Handle
      ```
      
      Since GHC was requiring that all data constructors of `Handle` be in
      scope. But `DeriveAnyClass` doesn't even generate code that mentions
      any data constructors, so this requirement is silly!
      
      Fixes #11509.
      
      Test Plan: make test TEST=T11509
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D2558
      
      GHC Trac Issues: #11509
      d5a4e49d
    • Ben Gamari's avatar
      Clean up handling of known-key Names in interface files · 34d933d6
      Ben Gamari authored
      Previously BinIface had some dedicated logic for handling tuple names in
      the symbol table. As it turns out, this logic was essentially dead code
      as it was superceded by the special handling of known-key things. Here
      we cull the tuple code-path and use the known-key codepath for all
      tuple-ish things.
      
      This had a surprising number of knock-on effects,
      
       * constraint tuple datacons had to be made known-key (previously they
         were not)
      
       * IfaceTopBndr was changed from being a synonym of OccName to a
         synonym of Name (since we now need to be able to deserialize Names
         directly from interface files)
      
       * the change to IfaceTopBndr complicated fingerprinting, since we need
         to ensure that we don't go looking for the fingerprint of the thing
         we are currently fingerprinting in the fingerprint environment (see
         notes in MkIface). Handling this required distinguishing between
         binding and non-binding Name occurrences in the Binary serializers.
      
       * the original name cache logic which previously lived in IfaceEnv has
         been moved to a new NameCache module
      
       * I ripped tuples and sums out of knownKeyNames since they introduce a
         very large number of entries. During interface file deserialization
         we use static functions (defined in the new KnownUniques module) to
         map from a Unique to a known-key Name (the Unique better correspond
         to a known-key name!) When we need to do an original name cache
         lookup we rely on the parser implemented in isBuiltInOcc_maybe.
      
       * HscMain.allKnownKeyNames was folded into PrelInfo.knownKeyNames.
      
       * Lots of comments were sprinkled about describing the new scheme.
      
      Updates haddock submodule.
      
      Test Plan: Validate
      
      Reviewers: niteria, simonpj, austin, hvr
      
      Reviewed By: simonpj
      
      Subscribers: simonmar, niteria, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2467
      
      GHC Trac Issues: #12532, #12415
      34d933d6
  2. 13 Oct, 2016 3 commits
  3. 12 Oct, 2016 4 commits
  4. 11 Oct, 2016 2 commits
    • Joachim Breitner's avatar
      Add a broken test case for #12689 · f8d2c205
      Joachim Breitner authored
      A rule with a phase specification trying to match on a constructor with
      a wrapper will fail to match, as the wrapper will be inlined by then.
      The fact that it works in the other case is also mostly by accident.
      (Split into two test cases so that regressions with regard what works so
      far are caught.)
      f8d2c205
    • Joachim Breitner's avatar
      Add test case for #12689 · b5be2ec3
      Joachim Breitner authored
      which test a few variants of rules involving constructors, including
      nullary constructors, constructors with wrappers, and unsaturated of
      constructors.
      
      At the moment, all the rules work as expected, despite GHC’s compile
      time warnings when called with -Wall.
      b5be2ec3
  5. 10 Oct, 2016 3 commits
    • Simon Peyton Jones's avatar
      More tests for Trac #12522 · a6111b8c
      Simon Peyton Jones authored
      These ones test the variations in coment:15 of the ticket
      a6111b8c
    • Simon Peyton Jones's avatar
      Improved stats for Trac #1969 · cc5ca21b
      Simon Peyton Jones authored
      With my latest commits
      
        76a5477b Move zonking out of tcFamTyPats
        b255ae7b Orient improvement constraints better
      
      perf has improved slightly for T1969:
      
      allocs:    733M -> 26M
      residency: 43M  -> 41M
      
      I don't know exactly why, but hey, it's good
      cc5ca21b
    • Simon Peyton Jones's avatar
      Orient improvement constraints better · b255ae7b
      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
      fine.
      
      See Note [Improvement orientation] in TcInteract, and some
      discussion on the Trac ticket.
      b255ae7b
  6. 08 Oct, 2016 5 commits
  7. 07 Oct, 2016 1 commit
  8. 06 Oct, 2016 1 commit
  9. 05 Oct, 2016 1 commit
  10. 02 Oct, 2016 9 commits
  11. 01 Oct, 2016 5 commits
    • Ben Gamari's avatar
      Mark T11978a as broken due to #12019 · d1b4fec1
      Ben Gamari authored
      Test Plan: `validate --slow`
      
      Reviewers: austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2536
      
      GHC Trac Issues: #12019
      d1b4fec1
    • Matthew Pickering's avatar
      Move -dno-debug-output to the end of the test flags · f869b23e
      Matthew Pickering authored
      It is often convenient to copy the test invocation and remove this flag
      in order to see compiler traces. Moving it to the end makes it easier to
      remove.
      
      Remove trailing whitespace
      
      Reviewers: austin, thomie, bgamari
      
      Reviewed By: bgamari
      
      Differential Revision: https://phabricator.haskell.org/D2543
      f869b23e
    • mniip's avatar
      GHCi: Don't remove shadowed bindings from typechecker scope. · 59d7ee53
      mniip authored
      The shadowed out bindings are accessible via qualified names like
      Ghci1.foo.  Since they are accessable in the renamer the typechecker
      should be able to see them too.  As a consequence they show up in :show
      bindings.
      
      This fixes T11547
      
      Test Plan:
      Fixed current tests to accomodate to new stuff in :show bindings
      Added a test that verifies that the typechecker doesn't crash
      
      Reviewers: austin, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2447
      
      GHC Trac Issues: #11547
      59d7ee53
    • Sylvain HENRY's avatar
      CodeGen X86: fix unsafe foreign calls wrt inlining · b61b7c24
      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
      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
      b61b7c24
    • Ryan Scott's avatar
      Implement deriving strategies · 9e862765
      Ryan Scott authored
      Allows users to explicitly request which approach to `deriving` to use
      via keywords, e.g.,
      
      ```
      newtype Foo = Foo Bar
        deriving Eq
        deriving stock    Ord
        deriving newtype Show
      ```
      
      Fixes #10598. Updates haddock submodule.
      
      Test Plan: ./validate
      
      Reviewers: hvr, kosmikus, goldfire, alanz, bgamari, simonpj, austin,
      erikd, simonmar
      
      Reviewed By: alanz, bgamari, simonpj
      
      Subscribers: thomie, mpickering, oerjan
      
      Differential Revision: https://phabricator.haskell.org/D2280
      
      GHC Trac Issues: #10598
      9e862765
  12. 30 Sep, 2016 4 commits
    • Simon Peyton Jones's avatar
      Make tcrun042 fail · 3f27237b
      Simon Peyton Jones authored
      This test uses wholesale impredicative polymorphism, and now fails.
      That's ok.
      3f27237b
    • Simon Peyton Jones's avatar
      Add missing stderr file · 5d473cd6
      Simon Peyton Jones authored
      ..accidentally omitted from previous commit.
      5d473cd6
    • Simon Peyton Jones's avatar
      Fix impredicativity (again) · b612da66
      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.
      
      Cure.
      
      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.
      b612da66
    • Simon Peyton Jones's avatar
      Fix a bug in occurs checking · 66a8c194
      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
             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.
      66a8c194