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

GHC ghc-devs at haskell.org
Wed Dec 2 21:44:41 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:                    |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 This is analogous to wanting this function to typecheck:

 {{{
 plusOne :: Int -> Int
 plusOne n = if True
             then n + 1
             else 'A'    -- unreachable
 }}}

 But the Haskell 98/Haskell 2010 standard says it should not typecheck:
 "The type of e1 must be Bool; e2 and e3 must have the same type, which is
 also the type of the entire conditional expression."

 The same for the original program, though the typing rules for record
 update are more complicated. But they similarly do not depend on knowledge
 about the value of the record-to-be-updated.

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


More information about the ghc-tickets mailing list