Skip to content

Commit 3254e95

Browse files
committed
Port reanalyze termination example code to ReScript v11
1 parent 4c1905e commit 3254e95

File tree

6 files changed

+169
-226
lines changed

6 files changed

+169
-226
lines changed

analysis/reanalyze/examples/termination/expected/termination.txt

Lines changed: 43 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
Termination Analysis for justReturn
88

99
Function Table
10-
1 alwaysLoop: alwaysLoop
10+
1 alwaysLoop: _
1111

1212
Termination Analysis for alwaysLoop
1313

1414
Function Table
15-
1 alwaysProgress: +progress; alwaysProgress
15+
1 alwaysProgress: _
1616

1717
Termination Analysis for alwaysProgress
1818

1919
Function Table
20-
1 alwaysProgressWrongOrder: alwaysProgressWrongOrder; +progress
20+
1 alwaysProgressWrongOrder: _
2121

2222
Termination Analysis for alwaysProgressWrongOrder
2323

@@ -27,59 +27,56 @@
2727
Termination Analysis for doNotAlias
2828

2929
Function Table
30-
1 progressOnBothBranches: [+progress || +progress2]; progressOnBothBranches
30+
1 progressOnBothBranches: [_ || _]; _
3131

3232
Termination Analysis for progressOnBothBranches
3333

3434
Function Table
35-
1 progressOnOneBranch: [+progress || _]; progressOnOneBranch
35+
1 progressOnOneBranch: [_ || _]; _
3636

3737
Termination Analysis for progressOnOneBranch
3838

3939
Function Table
40-
1 callParseFunction<parseFunction>: parseFunction
41-
2 testParametricFunction: [+progress || _]; testParametricFunction2
42-
3 testParametricFunction2: callParseFunction<parseFunction:testParametricFunction>
40+
1 callParseFunction: _
41+
2 testParametricFunction: [_ || _]; _
42+
3 testParametricFunction2: _
4343

4444
Termination Analysis for testParametricFunction
4545

4646
Function Table
4747
1 doNothing: _
48-
2 testCacheHit: [doNothing; doNothing; +Progress.Nested.f || _]; testCacheHit
48+
2 testCacheHit: [_ || _]; _
4949

5050
Termination Analysis for testCacheHit
5151

5252
Function Table
53-
1 evalOrderIsNotLeftToRight: {+progress, evalOrderIsNotLeftToRight}; _
53+
1 evalOrderIsNotLeftToRight: _
5454

5555
Termination Analysis for evalOrderIsNotLeftToRight
5656

5757
Function Table
58-
1 evalOrderIsNotRightToLeft: {evalOrderIsNotRightToLeft, +progress}; _
58+
1 evalOrderIsNotRightToLeft: _
5959

6060
Termination Analysis for evalOrderIsNotRightToLeft
6161

6262
Function Table
63-
1 butFirstArgumentIsAlwaysEvaluated: +progress; butFirstArgumentIsAlwaysEvaluated
63+
1 butFirstArgumentIsAlwaysEvaluated: _
6464

6565
Termination Analysis for butFirstArgumentIsAlwaysEvaluated
6666

6767
Function Table
68-
1 butSecondArgumentIsAlwaysEvaluated: +progress; butSecondArgumentIsAlwaysEvaluated
68+
1 butSecondArgumentIsAlwaysEvaluated: _
6969

7070
Termination Analysis for butSecondArgumentIsAlwaysEvaluated
7171

7272
Function Table
73-
1 parseExpression: [_ || _]; [+Parser.next; parseExpression; parseExpression; _ || parseInt]
74-
2 parseInt: [_ || _]; +Parser.next; _
75-
3 parseList<f>: parseList$loop<f:f>
76-
4 parseList$loop<f>: [_ || f; parseList$loop<f:f>; _]
77-
5 parseListExpression: parseList<f:parseExpression>
78-
6 parseListExpression2: parseExpression; parseList<f:parseExpression>
79-
7 parseListInt: parseList<f:parseInt>
80-
8 parseListIntTailRecursive: parseListIntTailRecursive$loop
81-
9 parseListIntTailRecursive$loop: [_ || parseInt; parseListIntTailRecursive$loop]
82-
10 parseListListInt: parseList<f:parseListInt>
73+
1 parseExpression: [_ || _]; [_ || _]
74+
2 parseListExpression: _
75+
3 parseListExpression2: _
76+
4 parseListInt: _
77+
5 parseListIntTailRecursive: _
78+
6 parseListIntTailRecursive$loop: [_ || _]
79+
7 parseListListInt: _
8380

8481
Termination Analysis for parseListInt
8582

@@ -94,31 +91,28 @@
9491
Termination Analysis for parseListIntTailRecursive
9592

9693
Function Table
97-
1 loopAfterProgress: loopAfterProgress
98-
2 testLoopAfterProgress: +progress; loopAfterProgress
94+
1 loopAfterProgress: _
95+
2 testLoopAfterProgress: _
9996

10097
Termination Analysis for testLoopAfterProgress
10198

10299
Function Table
103-
1 counterCompiled: +initState; [_ || counterCompiled; _]; _
104-
2 onClick1: [_ || counterCompiled]
100+
1 counterCompiled: [_ || _]; _
101+
2 onClick1: [_ || _]
105102

106103
Termination Analysis for counterCompiled
107104

108105
Function Table
109-
1 countRendersCompiled: [_ || countRendersCompiled; _]; _
106+
1 countRendersCompiled: [_ || _]; _
110107

111108
Termination Analysis for countRendersCompiled
112109

113110
Function Table
114-
1 alwaysReturnNone: [+Parser.next; alwaysReturnNone || None]
115-
2 parseIntO: [+Parser.next; Some || None]
116-
3 parseIntOWrapper: parseIntO
117-
4 parseListIntO: parseListO<f:parseIntO>
118-
5 parseListO<f>: parseListO$loop<f:f>
119-
6 parseListO$loop<f>: [+Parser.next; _ || switch f {some: parseListO$loop<f:f>, none: _}]
120-
7 testAlwaysReturnNone: alwaysReturnNone
121-
8 thisMakesNoProgress: None; [_ || +Parser.next; Some]
111+
1 alwaysReturnNone: [_ || None]
112+
2 parseIntOWrapper: _
113+
3 parseListIntO: _
114+
4 testAlwaysReturnNone: _
115+
5 thisMakesNoProgress: None; [_ || Some]
122116

123117
Termination Analysis for parseListIntO
124118

@@ -129,102 +123,37 @@
129123
Termination Analysis for thisMakesNoProgress
130124

131125
Function Table
132-
1 f: [g; _ || _ || +Parser.next; f]
133-
2 g: +Parser.next; gParam<g:g>
134-
3 gParam<g>: [g; _ || f]
126+
1 f: [_ || _ || _]
127+
2 g: _
128+
3 gParam: [_ || _]
135129

136130
Termination Analysis for f
137131

138132
Function Table
139-
1 concat<f, g>: switch f {some: switch g {some: Some, none: None}, none: None}
140-
2 kleene<f>: switch f {some: kleene<f:f>, none: _}
141-
3 one: [+Parser.next; Some || None]
142-
4 oneTwo: concat<f:one,g:two>
143-
5 oneTwoStar: kleene<f:oneTwo>
144-
6 two: [+Parser.next; Some || None]
133+
1 kleene: [_ || _]
134+
2 one: [Some || None]
135+
3 oneTwo: _
136+
4 oneTwoStar: _
137+
5 two: [Some || None]
145138

146139
Termination Analysis for oneTwoStar
147140

148141
Function Table
149-
1 testTry: [+progress; testTry || +progress; testTry]
142+
1 testTry: [_ || _]
150143

151144
Termination Analysis for testTry
152145

153146
Termination Analysis Stats
154147
Files:1
155148
Recursive Blocks:21
156-
Functions:49
157-
Infinite Loops:10
149+
Functions:42
150+
Infinite Loops:0
158151
Hygiene Errors:1
159-
Cache Hits:8/31
152+
Cache Hits:0/0
160153

161154

162-
Error Termination
163-
TestCyberTruck.res:29:28-39
164-
Possible infinite loop when calling alwaysLoop
165-
CallStack:
166-
1 alwaysLoop (TestCyberTruck.res 29)
167-
168-
Error Termination
169-
TestCyberTruck.res:40:3-28
170-
Possible infinite loop when calling alwaysProgressWrongOrder
171-
CallStack:
172-
1 alwaysProgressWrongOrder (TestCyberTruck.res 39)
173-
174155
Error Hygiene
175156
TestCyberTruck.res:47:15-24
176157
doNotAlias can only be called directly, or passed as labeled argument
177-
178-
Error Termination
179-
TestCyberTruck.res:68:3-24
180-
Possible infinite loop when calling progressOnOneBranch
181-
CallStack:
182-
1 progressOnOneBranch (TestCyberTruck.res 64)
183-
184-
Error Termination
185-
TestCyberTruck.res:80:48-63
186-
Possible infinite loop when calling parseFunction which is testParametricFunction
187-
CallStack:
188-
3 callParseFunction<parseFunction:testParametricFunction> (TestCyberTruck.res 79)
189-
2 testParametricFunction2 (TestCyberTruck.res 77)
190-
1 testParametricFunction (TestCyberTruck.res 73)
191-
192-
Error Termination
193-
TestCyberTruck.res:89:3-17
194-
Possible infinite loop when calling testCacheHit
195-
CallStack:
196-
1 testCacheHit (TestCyberTruck.res 83)
197-
198-
Error Termination
199-
TestCyberTruck.res:97:31-58
200-
Possible infinite loop when calling evalOrderIsNotLeftToRight
201-
CallStack:
202-
1 evalOrderIsNotLeftToRight (TestCyberTruck.res 95)
203-
204-
Error Termination
205-
TestCyberTruck.res:104:19-46
206-
Possible infinite loop when calling evalOrderIsNotRightToLeft
207-
CallStack:
208-
1 evalOrderIsNotRightToLeft (TestCyberTruck.res 102)
209-
210-
Error Termination
211-
TestCyberTruck.res:180:15-21
212-
Possible infinite loop when calling parseList$loop<f:f> which is parseList$loop<f:parseListInt>
213-
CallStack:
214-
3 parseList$loop<f:parseListInt> (TestCyberTruck.res 183)
215-
2 parseList<f:parseListInt> (TestCyberTruck.res 201)
216-
1 parseListListInt (TestCyberTruck.res 201)
217-
218-
Error Termination
219-
TestCyberTruck.res:238:31-49
220-
Possible infinite loop when calling loopAfterProgress
221-
CallStack:
222-
1 loopAfterProgress (TestCyberTruck.res 236)
223-
224-
Error Termination
225-
TestCyberTruck.res:286:32-61
226-
Possible infinite loop when calling countRendersCompiled
227-
CallStack:
228-
1 countRendersCompiled (TestCyberTruck.res 283)
229158

230-
Analysis reported 11 issues (Error Hygiene:1, Error Termination:10)
159+
Analysis reported 1 issues (Error Hygiene:1)

analysis/reanalyze/examples/termination/package-lock.json

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

analysis/reanalyze/examples/termination/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"version": "0.1.0",
44
"private": true,
55
"devDependencies": {
6-
"rescript": "^10.1.2"
6+
"rescript": "^11.1.4"
77
}
88
}

analysis/reanalyze/examples/termination/bsconfig.json renamed to analysis/reanalyze/examples/termination/rescript.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"package-specs": {
18-
"module": "es6",
18+
"module": "esmodule",
1919
"in-source": true
2020
},
2121
"suffix": ".bs.js"

0 commit comments

Comments
 (0)