[GHC] #15398: GADT deriving Ord generates inaccessible code in a pattern with constructor.

GHC ghc-devs at haskell.org
Tue Jul 24 13:51:57 UTC 2018


#15398: GADT deriving Ord generates inaccessible code in a pattern with
constructor.
-------------------------------------+-------------------------------------
        Reporter:  philderbeast      |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:  deriving,
                                     |  PatternMatchWarnings
Operating System:  MacOS X           |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #8128 #8740       |  Differential Rev(s):  Phab:D4993
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Krzysztof Gogolewski <krz.gogolewski@…>):

 In [changeset:"44a7b9baa45c4ab939c7d996519b5e3de3e13c5a/ghc" 44a7b9b/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="44a7b9baa45c4ab939c7d996519b5e3de3e13c5a"
 Suppress -Winaccessible-code in derived code

 Summary:
 It's rather unfortunate that derived code can produce inaccessible
 code warnings (as demonstrated in #8128, #8740, and #15398), since
 the programmer has no control over the generated code. This patch
 aims to suppress `-Winaccessible-code` in all derived code. It
 accomplishes this by doing the following:

 * Generalize the `ic_env :: TcLclEnv` field of `Implication` to
   be of type `Env TcGblEnc TcLclEnv` instead. This way, it also
   captures `DynFlags`, which record the flag state at the time
   the `Implication` was created.
 * When typechecking derived code, turn off `-Winaccessible-code`.
   This way, any insoluble given `Implication`s that are created when
   typechecking this derived code will remember that
   `-Winaccessible-code` was disabled.
 * During error reporting, consult the `DynFlags` of an
   `Implication` before making the decision to report an inaccessible
   code warning.

 Test Plan: make test TEST="T8128 T8740 T15398"

 Reviewers: simonpj, bgamari

 Reviewed By: simonpj

 Subscribers: monoidal, rwbarton, thomie, carter

 GHC Trac Issues: #8128, #8740, #15398

 Differential Revision: https://phabricator.haskell.org/D4993
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15398#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list