1. 30 Oct, 2015 1 commit
    • Simon Peyton Jones's avatar
      Fix unused-import stuff in a better way · 9376249b
      Simon Peyton Jones authored
      The fix for Trac #10890 in commit 1818b48e, namely
         Fix incorrect import warnings when methods with identical names are imported
      was wrong, as demonstrated by the new test T10890_2.  It suppressed
      far too many warnings!
      
      This patch fixes the original problem in a different way, by making
      RdrName.greUsedRdrName a bit cleverer.
      
      But this too is not really the Right Thing.  I think the Right Thing is
      to store the /GRE/ in the tcg_used_rdrnames, not the /RdrName/.  That
      would be a lot simpler and more direct.
      
      But one step at a time.
      9376249b
  2. 13 Oct, 2015 1 commit
    • Ömer Sinan Ağacan's avatar
      Fix incorrect import warnings when methods with identical names are imported · 1818b48e
      Ömer Sinan Ağacan authored
      Currently, GHC's warning generation code is assuming that a name (`RdrName`)
      can be imported at most once. This is a correct assumption, because 1) it's OK
      to import same names as long as we don't use any of them 2) when we use one of
      them, GHC generates an error because it doesn't disambiguate it automatically.
      
      But apparently the story is different with typeclass methods. If I import two
      methods with same names, it's OK to use them in typeclass instance
      declarations, because the context specifies which one to use. For example, this
      is OK (where modules A and B define typeclasses A and B, both with a function
      has),
      
          import A
          import B
      
          data Blah = Blah
      
          instance A Blah where
            has = Blah
      
          instance B Blah where
            has = Blah
      
      But GHC's warning generator is not taking this into account, and so if I change
      import list of this program to:
      
          import A (A (has))
          import B (B (has))
      
      GHC is printing these warnings:
      
          Main.hs:5:1: Warning:
              The import of ‘A.has’ from module ‘A’ is redundant
      
          Main.hs:6:1: Warning:
              The import of ‘B.has’ from module ‘B’ is redundant
      
      Why? Because warning generation code is _silently_ ignoring multiple symbols
      with same names.
      
      With this patch, GHC takes this into account. If there's only one name, then
      this patch reduces to the previous version, that is, it works exactly the same
      as current GHC (thanks goes to @quchen for realizing this).
      
      Reviewed By: austin
      
      Differential Revision: https://phabricator.haskell.org/D1257
      
      GHC Trac Issues: #10890
      1818b48e