[GHC] #15954: LiberalTypeSynonyms unsaturation check doesn't kick in

GHC ghc-devs at haskell.org
Mon Dec 3 12:47:19 UTC 2018


#15954: LiberalTypeSynonyms unsaturation check doesn't kick in
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.6.3
       Component:  Compiler (Type    |              Version:  8.6.2
  checker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC accepts       |  Unknown/Multiple
  invalid program                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D5402
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ryan Scott <ryan.gl.scott@…>):

 In [changeset:"2e6cc3d08f8439a2c0b6426e839d80072dbcda2c/ghc" 2e6cc3d/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="2e6cc3d08f8439a2c0b6426e839d80072dbcda2c"
 Fix #15954 by rejigging check_type's order

 Summary:
 Previously, `check_type` (which catches illegal uses of
 unsaturated type synonyms without enabling `LiberalTypeSynonyms`,
 among other things) always checks for uses of polytypes before
 anything else. There is a problem with this plan, however:
 checking for polytypes requires decomposing `forall`s and other
 invisible arguments, an action which itself expands type synonyms!
 Therefore, if we have something like:

 ```lang=haskell
 type A a = Int
 type B (a :: Type -> Type) = forall x. x -> x
 type C = B A
 ```

 Then when checking `B A`, `A` will get expanded to `forall x. x -> x`
 before `check_type` has an opportunity to realize that `A` is an
 unsaturated type synonym! This is the root cause of #15954.

 This patch fixes the issue by moving the case of `check_type` that
 detects polytypes to be //after// the case that checks for
 `TyConApp`s. That way, the `TyConApp` case will properly flag things
 like the unsaturated use of `A` in the example above before we ever
 attempt to check for polytypes.

 Test Plan: make test TEST=T15954

 Reviewers: simonpj, bgamari, goldfire

 Reviewed By: simonpj

 Subscribers: rwbarton, carter

 GHC Trac Issues: #15954

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

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


More information about the ghc-tickets mailing list