[GHC] #11156: Type-changing record update catch-all in sum type doesn't typecheck

GHC ghc-devs at haskell.org
Wed Dec 2 21:30:54 UTC 2015


#11156: Type-changing record update catch-all in sum type doesn't typecheck
-------------------------------------+-------------------------------------
        Reporter:  afarmer           |                Owner:
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  7.10.2
  checker)                           |
      Resolution:  invalid           |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by simonpj):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 GHC typechecks this
 {{{
 ordify :: R Char -> R Int
 ordify r@(Foo {}) = r { x = ord (x r), y = ord (y r) }
 ordify r          = r { x = ord (x r) }
 }}}
 as if you had written this:
 {{{
 ordify :: R Char -> R Int
 ordify r@(Foo {}) = r { x = ord (x r), y = ord (y r) }
 ordify r          = case r of
                        Foo x y -> Foo (ord x) y   -- Eeek!
                        Bar x   -> Bar (ord x)
                        Baz x   -> Bar (ord x)
 }}}
 The `Eeek!` line elicits the complaint.

 You may say that the `Foo` case is already dealt with, so this branch of
 the case is dead code, but in general that require sophisticated
 reasoning, certainly more than the type checker can do.

 So I don't see a way to fix this; sorry.

 I'll close as "invalid" because GHC is behaving as advertised; but the
 goal is not invalid of course!

 Simon

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


More information about the ghc-tickets mailing list