[GHC] #15057: Lint types created by newFamInst

GHC ghc-devs at haskell.org
Fri Apr 20 03:00:32 UTC 2018


#15057: Lint types created by newFamInst
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.1
      Resolution:                    |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #15012            |  Differential Rev(s):  Phab:D4611
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"257c13d86db0a9ed540287127fd1c79abacf857e/ghc"
 257c13d8/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="257c13d86db0a9ed540287127fd1c79abacf857e"
 Lint types in newFamInst

 We weren't linting the types used in `newFamInst`, which
 might have been why #15012 went undiscovered for so long. Let's fix
 that.

 One has to be surprisingly careful with expanding type synonyms in
 `lintType`, since in the offending program (simplified):

 ```lang=haskell
 type FakeOut a = Int

 type family TF a
 type instance TF Int = FakeOut a
 ```

 If one expands type synonyms, then `FakeOut a` will expand to
 `Int`, which masks the issue (that `a` is unbound). I added an
 extra Lint flag to configure whether type synonyms should be
 expanded or not in Lint, and disabled this when calling `lintTypes`
 from `newFamInst`.

 As evidence that this works, I ran it on the offending program
 from #15012, and voilà:

 ```
 $ ghc3/inplace/bin/ghc-stage2 Bug.hs -dcore-lint
 [1 of 1] Compiling Foo              ( Bug.hs, Bug.o )
 ghc-stage2: panic! (the 'impossible' happened)
   (GHC version 8.5.20180417 for x86_64-unknown-linux):
         Core Lint error
   <no location info>: warning:
       In the type ‘... (Rec0 (FakeOut b_a1Qt))))’
       @ b_a1Qt is out of scope
 ```

 Test Plan: make test TEST=T15057

 Reviewers: simonpj, goldfire, bgamari

 Reviewed By: bgamari

 Subscribers: thomie, carter

 GHC Trac Issues: #15057

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

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


More information about the ghc-tickets mailing list