#5334: record wildcards: field not initialised reported as type error
---------------------------------+------------------------------------------
    Reporter:  aruiz             |       Owner:                           
        Type:  bug               |      Status:  new                      
    Priority:  normal            |   Component:  Compiler                 
     Version:  7.0.4             |    Keywords:                           
    Testcase:                    |   Blockedby:                           
          Os:  Unknown/Multiple  |    Blocking:                           
Architecture:  Unknown/Multiple  |     Failure:  GHC rejects valid program
---------------------------------+------------------------------------------
 I think that the following program should be accepted, with warnings about
 not initialized fields:

 {{{
 {-# LANGUAGE RecordWildCards #-}

 data T = T { a, b :: Int }

 t = T {..}
   where
      a = 1
      -- b = 2

 data S = S { x, y :: Int }

 s = S { x = 1 }

 }}}

 but it produces

 {{{
 $ ghci bugrecord.hs
 GHCi, version 7.0.4: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package ffi-1.0 ... linking ... done.
 [1 of 1] Compiling Main             ( bugrecord.hs, interpreted )

 bugrecord.hs:5:5:
     Couldn't match expected type `Int' with actual type `T -> Int'
     In the `b' field of a record
     In the expression: T {..}
     In an equation for `t':
         t = T {..}
           where
               a = 1
 Failed, modules loaded: none.
 }}}

 If we uncomment the definition of field b the program is accepted, with a
 correct warning about the undefined field y in the other record.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5334>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to