Skip to content

Commit 9611fd5

Browse files
authored
Add reproducer for #4645 (#5196)
This replicates the code in issue #4645, which should show if we have a bug or not. In fact, it seems the issue doesn't reproduce.
1 parent bb9b5a1 commit 9611fd5

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

plutus-tx-plugin/test/Plugin/Strict/Spec.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ strict = testNested "Strict" [
3030
, goldenPir "strictPair" strictPair
3131
, goldenPir "strictList" strictList
3232
, goldenPir "strictData" strictData
33+
, goldenPir "issue4645" issue4645
34+
, goldenEvalCekLog "issue4645Eval" [ issue4645 ]
3335
]
3436

3537
strictAdd :: CompiledCode (Integer -> Integer -> Integer)
@@ -82,3 +84,20 @@ strictData = plc (Proxy @"strictData") strictDataExample
8284

8385
strictDataExample :: BI.BuiltinData -> Integer
8486
strictDataExample !d = BI.unsafeDataAsI d
87+
88+
issue4645 :: CompiledCode Bool
89+
issue4645 = plc (Proxy @"issue4645") issue4645Example
90+
91+
-- Reproducer for plutus#4645
92+
issue4645Example :: Bool
93+
issue4645Example =
94+
let
95+
!x = P.trace "x" 0 :: Integer
96+
!y = P.trace "y" (1, 2) :: (Integer,Integer)
97+
!z = P.trace "z" y
98+
(!zz, _) = P.trace "zz" z
99+
!t = P.trace "t" zz
100+
101+
!valid = x P.== t
102+
in valid
103+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
(program
2+
1.1.0
3+
(let
4+
(nonrec)
5+
(datatypebind
6+
(datatype
7+
(tyvardecl Tuple2 (fun (type) (fun (type) (type))))
8+
(tyvardecl a (type)) (tyvardecl b (type))
9+
Tuple2_match
10+
(vardecl Tuple2 (fun a (fun b [ [ Tuple2 a ] b ])))
11+
)
12+
)
13+
(datatypebind
14+
(datatype
15+
(tyvardecl Bool (type))
16+
17+
Bool_match
18+
(vardecl True Bool) (vardecl False Bool)
19+
)
20+
)
21+
(termbind
22+
(strict)
23+
(vardecl y [ [ Tuple2 (con integer) ] (con integer) ])
24+
[
25+
[
26+
{ (builtin trace) [ [ Tuple2 (con integer) ] (con integer) ] }
27+
(con string "y")
28+
]
29+
[
30+
[ { { Tuple2 (con integer) } (con integer) } (con integer 1) ]
31+
(con integer 2)
32+
]
33+
]
34+
)
35+
(termbind
36+
(strict)
37+
(vardecl z [ [ Tuple2 (con integer) ] (con integer) ])
38+
[
39+
[
40+
{ (builtin trace) [ [ Tuple2 (con integer) ] (con integer) ] }
41+
(con string "z")
42+
]
43+
y
44+
]
45+
)
46+
(termbind
47+
(strict)
48+
(vardecl t (con integer))
49+
[
50+
[ { (builtin trace) (con integer) } (con string "t") ]
51+
[
52+
{
53+
[
54+
{ { Tuple2_match (con integer) } (con integer) }
55+
[
56+
[
57+
{ (builtin trace) [ [ Tuple2 (con integer) ] (con integer) ] }
58+
(con string "zz")
59+
]
60+
z
61+
]
62+
]
63+
(con integer)
64+
}
65+
(lam zz (con integer) (lam ds (con integer) zz))
66+
]
67+
]
68+
)
69+
(termbind
70+
(strict)
71+
(vardecl x (con integer))
72+
[ [ { (builtin trace) (con integer) } (con string "x") ] (con integer 0) ]
73+
)
74+
[
75+
[
76+
[ { (builtin ifThenElse) Bool } [ [ (builtin equalsInteger) x ] t ] ]
77+
True
78+
]
79+
False
80+
]
81+
)
82+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[y, z, zz, t, x]

0 commit comments

Comments
 (0)