Commit 022a7384 authored by kevind's avatar kevind
Browse files

Add test for unboxed fields in GADT record selectors

parent f9d1d672
......@@ -36,6 +36,7 @@ test('tdpe', normal, compile, [''])
test('Nilsson', skip_if_fast, compile, [''])
test('records', skip_if_fast, compile_and_run, [''])
test('ubx-records', skip_if_fast, compile_and_run, [''])
test('records-fail1', normal, compile_fail, [''])
# New ones from Dimitrios
......
{-# OPTIONS -fglasgow-exts -funbox-strict-fields #-}
-- Tests record selectors with unboxed fields for GADTs
module Main where
data T a where
T1 { w :: !(Int, Int), x :: a, y :: b } :: T (a,b)
T2 { w :: !(Int, Int), x :: a } :: T (a,b)
T3 { z :: Int } :: T Bool
f xv yv = T1 { w = (0,0), x = xv, y = yv }
g :: T a -> T a
g (T1 {x=xv, y=yv}) = T2 { w = (0,0), x = xv }
-- h :: Num a => T a any -> a
h v = x v + 1
i v = let (x,y) = w v in x + y
main = do { let t1 = T1 { w = (0,0), y = "foo", x = 4 }
t2 = g t1
; print (h (f 8 undefined))
; print (h t2)
; print (i t1)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment