Skip to content

Commit abc1373

Browse files
committed
Add test for #239
Tests UNPACKed fields with record labels are not broken
1 parent a76086b commit abc1373

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

test/golden/T239/Main.hs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{-# OPTIONS_GHC -O -fno-unoptimized-core-for-interpreter #-}
2+
{-# LANGUAGE BangPatterns #-}
3+
4+
module Main where
5+
6+
data Packed = Packed -- Unpacking only happens with optimizations, hence the -O.
7+
{ packedLeft :: {-# UNPACK #-} !Char
8+
, packedRight :: {-# UNPACK #-} !Char
9+
}
10+
deriving Show
11+
12+
data Container = Container
13+
{ containerBefore :: Int
14+
, containerPacked :: {-# UNPACK #-} !Packed
15+
, containerPacked2 :: {-# UNPACK #-} !Packed
16+
, containerAfter :: Int
17+
}
18+
deriving Show
19+
20+
mkContainer :: Container
21+
mkContainer = Container 10 (Packed 'a' 'b') (Packed 'c' 'd') 40
22+
{-# OPAQUE mkContainer #-}
23+
24+
main :: IO ()
25+
main = do
26+
let !container = mkContainer
27+
const (pure ()) container
28+
print container
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[1 of 3] Compiling GHC.Debugger.View.Class ( in-memory:GHC.Debugger.View.Class, interpreted )[haskell-debugger-view-in-memory]
2+
[2 of 3] Compiling Main ( <TEMPORARY-DIRECTORY>/Main.hs, interpreted )[main]
3+
(hdb) BreakFound {changed = True, breakId = [InternalBreakpointId Main 2], sourceSpan = SourceSpan {file = "<TEMPORARY-DIRECTORY>/Main.hs", startLine = 27, endLine = 27, startCol = 3, endCol = 28}}
4+
(hdb) Stopped at breakpoint
5+
(hdb) _result : IO () = <fn> :: IO ()
6+
container : Container = Container
7+
containerBefore : Int = _
8+
containerPacked : Packed = Packed
9+
containerPacked2 : Packed = Packed
10+
containerAfter : Int = _
11+
(hdb) (hdb) Exiting...
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$HDB Main.hs -v 0 < T239.hdb-stdin

test/golden/T239/T239.hdb-stdin

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
break Main.hs 27
2+
run
3+
variables
4+
exit

0 commit comments

Comments
 (0)