Skip to content

Commit e15f6e4

Browse files
committed
internal/core/adt: treat for loop values as non-cyclic
Issue #3903 had a spurious structural cycle. The issue was that the #Schema value of the list was recognized as a cyclic value, even though it was a new introduction. New introductions were marked by insertConjunct, but some paths, like for comprehensions, would use scheduleConjunct directly and thus bypassing this mechanism. This would cause a value to NOT be marked as noncyclic. Fixes #3903 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ib739cf493faf22834b58e476a1328edd8688bf8c Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1215594 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 4a4d9ef commit e15f6e4

File tree

8 files changed

+167
-190
lines changed

8 files changed

+167
-190
lines changed

cue/testdata/cycle/023_reentrance.txtar

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ NumCloseIDs: 41
7676
-- out/evalalpha --
7777
Errors:
7878
structural cycle:
79-
./in.cue:3:25
79+
./in.cue:8:9
80+
structural cycle:
81+
./in.cue:8:38
8082

8183
Result:
8284
(_|_){
@@ -104,21 +106,24 @@ Result:
104106
n: (int){ int }
105107
}
106108
fib1: (int){ 1 }
107-
fib2: (_|_){
108-
// [structural cycle] structural cycle:
109-
// ./in.cue:3:25
110-
}
109+
fib2: (int){ 1 }
111110
fib3: (_|_){
112111
// [structural cycle] structural cycle:
113-
// ./in.cue:3:25
112+
// ./in.cue:8:9
113+
// structural cycle:
114+
// ./in.cue:8:38
114115
}
115116
fib7: (_|_){
116117
// [structural cycle] structural cycle:
117-
// ./in.cue:3:25
118+
// ./in.cue:8:9
119+
// structural cycle:
120+
// ./in.cue:8:38
118121
}
119122
fib12: (_|_){
120123
// [structural cycle] structural cycle:
121-
// ./in.cue:3:25
124+
// ./in.cue:8:9
125+
// structural cycle:
126+
// ./in.cue:8:38
122127
}
123128
}
124129
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
@@ -151,49 +156,39 @@ diff old new
151156
diff old new
152157
--- old
153158
+++ new
154-
@@ -1,10 +1,6 @@
159+
@@ -1,7 +1,5 @@
155160
Errors:
156161
structural cycle:
157-
./in.cue:3:25
158-
-structural cycle:
159-
- ./in.cue:8:9
162+
- ./in.cue:3:25
160163
-structural cycle:
161-
- ./in.cue:8:38
162-
163-
Result:
164-
(_|_){
165-
@@ -32,27 +28,20 @@
166-
n: (int){ int }
167-
}
168-
fib1: (int){ 1 }
169-
- fib2: (int){ 1 }
170-
+ fib2: (_|_){
171-
+ // [structural cycle] structural cycle:
172-
+ // ./in.cue:3:25
173-
+ }
164+
./in.cue:8:9
165+
structural cycle:
166+
./in.cue:8:38
167+
@@ -35,14 +33,12 @@
168+
fib2: (int){ 1 }
174169
fib3: (_|_){
175170
// [structural cycle] structural cycle:
176-
// ./in.cue:3:25
177-
- // structural cycle:
178-
- // ./in.cue:8:38
171+
- // ./in.cue:3:25
172+
+ // ./in.cue:8:9
173+
// structural cycle:
174+
// ./in.cue:8:38
179175
}
180176
fib7: (_|_){
181177
// [structural cycle] structural cycle:
182-
// ./in.cue:3:25
178+
- // ./in.cue:3:25
183179
- // structural cycle:
184-
- // ./in.cue:8:9
185-
- // structural cycle:
186-
- // ./in.cue:8:38
180+
// ./in.cue:8:9
181+
// structural cycle:
182+
// ./in.cue:8:38
183+
@@ -49,8 +45,6 @@
187184
}
188185
fib12: (_|_){
189186
// [structural cycle] structural cycle:
190-
// ./in.cue:3:25
191-
- // structural cycle:
192-
- // ./in.cue:8:9
187+
- // ./in.cue:3:25
193188
- // structural cycle:
194-
- // ./in.cue:8:38
195-
}
196-
}
189+
// ./in.cue:8:9
190+
// structural cycle:
191+
// ./in.cue:8:38
197192
-- diff/todo/p3 --
198193
Note that it is okay for fib2 to fail.
199194
-- out/eval/stats --

cue/testdata/cycle/builtins.txtar

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,18 @@ issue3634: reduced: {
255255
out: len(#D & list.Repeat([#D & { a: b: 1 }], 1)[0])
256256
}
257257
-- out/evalalpha/stats --
258-
Leaks: 466
258+
Leaks: 478
259259
Freed: 0
260260
Reused: 0
261-
Allocs: 466
261+
Allocs: 478
262262
Retain: 0
263263

264-
Unifications: 399
265-
Conjuncts: 731
266-
Disjuncts: 38
264+
Unifications: 407
265+
Conjuncts: 745
266+
Disjuncts: 42
267267

268-
CloseIDElems: 116
269-
NumCloseIDs: 189
268+
CloseIDElems: 122
269+
NumCloseIDs: 191
270270
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
271271
diff old new
272272
--- old
@@ -281,18 +281,18 @@ diff old new
281281
-Unifications: 441
282282
-Conjuncts: 821
283283
-Disjuncts: 537
284-
+Leaks: 466
284+
+Leaks: 478
285285
+Freed: 0
286286
+Reused: 0
287-
+Allocs: 466
287+
+Allocs: 478
288288
+Retain: 0
289289
+
290-
+Unifications: 399
291-
+Conjuncts: 731
292-
+Disjuncts: 38
290+
+Unifications: 407
291+
+Conjuncts: 745
292+
+Disjuncts: 42
293293
+
294-
+CloseIDElems: 116
295-
+NumCloseIDs: 189
294+
+CloseIDElems: 122
295+
+NumCloseIDs: 191
296296
-- out/eval/stats --
297297
Leaks: 25
298298
Freed: 446

0 commit comments

Comments
 (0)