...
1-- x.cue --
2// variants of fib
3
4inline: small: {
5 f: {
6 n: int
7 out: (f & {"n": n - 1}).out
8 }
9}
10
11inline: medium: {
12 f2: (f & {n: 2}).out
13 fRec: {nn: int, out: (f & {n: nn}).out}
14 f: {
15 n: int
16 out: (fRec & {nn: n - 1}).out
17 }
18}
19
20inline: patterns: {
21 f: n: (f & {n: {}}).n
22 f: n: {}
23 [string]: {n: {}}
24 f: [string]: {}
25 f: {}
26}
27
28inline: acrossFields: fail1: {
29 f: {
30 in: number
31 out: in + 1
32 }
33 k00: 0
34 k10: (f & {in: k00}).out
35 k20: (f & {in: k10}).out
36 k30: (f & {in: k20}).out
37
38 // invalid recursion is here.
39 k10: (f & {in: k30}).out
40}
41
42// Issue #2163
43inline: acrossFields: ok1: {
44 f: {
45 in: number
46 out: in
47 }
48 k00: 0
49 k10: (f & {in: k00}).out
50 k20: (f & {in: k10}).out
51 k30: (f & {in: k20}).out
52
53 // TODO: what is correct behavior here.
54 // This is borderline okay.
55 k10: (f & {in: k30}).out
56}
57-- out/compile --
58--- x.cue
59{
60 inline: {
61 small: {
62 f: {
63 n: int
64 out: (〈1;f〉 & {
65 n: (〈1;n〉 - 1)
66 }).out
67 }
68 }
69 }
70 inline: {
71 medium: {
72 f2: (〈0;f〉 & {
73 n: 2
74 }).out
75 fRec: {
76 nn: int
77 out: (〈1;f〉 & {
78 n: 〈1;nn〉
79 }).out
80 }
81 f: {
82 n: int
83 out: (〈1;fRec〉 & {
84 nn: (〈1;n〉 - 1)
85 }).out
86 }
87 }
88 }
89 inline: {
90 patterns: {
91 f: {
92 n: (〈1;f〉 & {
93 n: {}
94 }).n
95 }
96 f: {
97 n: {}
98 }
99 [string]: {
100 n: {}
101 }
102 f: {
103 [string]: {}
104 }
105 f: {}
106 }
107 }
108 inline: {
109 acrossFields: {
110 fail1: {
111 f: {
112 in: number
113 out: (〈0;in〉 + 1)
114 }
115 k00: 0
116 k10: (〈0;f〉 & {
117 in: 〈1;k00〉
118 }).out
119 k20: (〈0;f〉 & {
120 in: 〈1;k10〉
121 }).out
122 k30: (〈0;f〉 & {
123 in: 〈1;k20〉
124 }).out
125 k10: (〈0;f〉 & {
126 in: 〈1;k30〉
127 }).out
128 }
129 }
130 }
131 inline: {
132 acrossFields: {
133 ok1: {
134 f: {
135 in: number
136 out: 〈0;in〉
137 }
138 k00: 0
139 k10: (〈0;f〉 & {
140 in: 〈1;k00〉
141 }).out
142 k20: (〈0;f〉 & {
143 in: 〈1;k10〉
144 }).out
145 k30: (〈0;f〉 & {
146 in: 〈1;k20〉
147 }).out
148 k10: (〈0;f〉 & {
149 in: 〈1;k30〉
150 }).out
151 }
152 }
153 }
154}
155-- out/eval/stats --
156Leaks: 247
157Freed: 141
158Reused: 136
159Allocs: 252
160Retain: 834
161
162Unifications: 388
163Conjuncts: 1307
164Disjuncts: 707
165-- out/eval --
166Errors:
167structural cycle:
168 ./x.cue:6:9
169structural cycle:
170 ./x.cue:15:9
171structural cycle:
172 ./x.cue:20:9
173in: structural cycle:
174 ./x.cue:30:8
175
176Result:
177(_|_){
178 // [structural cycle]
179 inline: (_|_){
180 // [structural cycle]
181 small: (_|_){
182 // [structural cycle]
183 f: (_|_){
184 // [structural cycle]
185 n: (int){ int }
186 out: (_|_){
187 // [structural cycle] structural cycle:
188 // ./x.cue:6:9
189 }
190 }
191 }
192 medium: (_|_){
193 // [structural cycle]
194 f2: (_|_){
195 // [structural cycle] structural cycle:
196 // ./x.cue:15:9
197 }
198 fRec: (_|_){
199 // [structural cycle]
200 nn: (int){ int }
201 out: (_|_){
202 // [structural cycle] structural cycle:
203 // ./x.cue:15:9
204 }
205 }
206 f: (_|_){
207 // [structural cycle]
208 n: (int){ int }
209 out: (_|_){
210 // [structural cycle] structural cycle:
211 // ./x.cue:15:9
212 }
213 }
214 }
215 patterns: (_|_){
216 // [structural cycle]
217 f: (_|_){
218 // [structural cycle]
219 n: (_|_){
220 // [structural cycle] structural cycle:
221 // ./x.cue:20:9
222 }
223 }
224 }
225 acrossFields: (_|_){
226 // [structural cycle]
227 fail1: (_|_){
228 // [structural cycle]
229 f: (struct){
230 in: (number){ number }
231 out: (_|_){
232 // [incomplete] inline.acrossFields.fail1.f.out: non-concrete value number in operand to +:
233 // ./x.cue:30:8
234 // ./x.cue:29:8
235 }
236 }
237 k00: (int){ 0 }
238 k10: (_|_){
239 // [structural cycle] in: structural cycle:
240 // ./x.cue:30:8
241 }
242 k20: (_|_){
243 // [structural cycle] in: structural cycle:
244 // ./x.cue:30:8
245 }
246 k30: (_|_){
247 // [structural cycle] in: structural cycle:
248 // ./x.cue:30:8
249 }
250 }
251 ok1: (struct){
252 f: (struct){
253 in: (number){ number }
254 out: (number){ number }
255 }
256 k00: (int){ 0 }
257 k10: (int){ 0 }
258 k20: (int){ 0 }
259 k30: (int){ 0 }
260 }
261 }
262 }
263}
264-- out/evalalpha --
265Errors:
266structural cycle:
267 ./x.cue:6:9
268structural cycle:
269 ./x.cue:12:24
270structural cycle:
271 ./x.cue:15:9
272structural cycle:
273 ./x.cue:20:9
274in: structural cycle:
275 ./x.cue:34:17
276in: structural cycle:
277 ./x.cue:35:17
278in: structural cycle:
279 ./x.cue:38:17
280in: structural cycle:
281 ./x.cue:49:17
282in: structural cycle:
283 ./x.cue:50:17
284in: structural cycle:
285 ./x.cue:54:17
286
287Result:
288(_|_){
289 // [structural cycle]
290 inline: (_|_){
291 // [structural cycle]
292 small: (_|_){
293 // [structural cycle]
294 f: (_|_){
295 // [structural cycle]
296 n: (int){ int }
297 out: (_|_){
298 // [structural cycle] structural cycle:
299 // ./x.cue:6:9
300 }
301 }
302 }
303 medium: (_|_){
304 // [structural cycle]
305 f2: (_|_){
306 // [structural cycle] structural cycle:
307 // ./x.cue:15:9
308 }
309 fRec: (_|_){
310 // [structural cycle]
311 nn: (int){ int }
312 out: (_|_){
313 // [structural cycle] structural cycle:
314 // ./x.cue:12:24
315 }
316 }
317 f: (_|_){
318 // [structural cycle]
319 n: (int){ int }
320 out: (_|_){
321 // [structural cycle] structural cycle:
322 // ./x.cue:15:9
323 }
324 }
325 }
326 patterns: (_|_){
327 // [structural cycle]
328 f: (_|_){
329 // [structural cycle]
330 n: (_|_){
331 // [structural cycle] structural cycle:
332 // ./x.cue:20:9
333 }
334 }
335 }
336 acrossFields: (_|_){
337 // [structural cycle]
338 fail1: (_|_){
339 // [structural cycle]
340 f: (struct){
341 in: (number){ number }
342 out: (_|_){
343 // [incomplete] inline.acrossFields.fail1.f.out: non-concrete value number in operand to +:
344 // ./x.cue:30:8
345 // ./x.cue:29:8
346 }
347 }
348 k00: (int){ 0 }
349 k10: (_|_){
350 // [structural cycle] in: structural cycle:
351 // ./x.cue:38:17
352 }
353 k20: (_|_){
354 // [structural cycle] in: structural cycle:
355 // ./x.cue:34:17
356 }
357 k30: (_|_){
358 // [structural cycle] in: structural cycle:
359 // ./x.cue:35:17
360 }
361 }
362 ok1: (_|_){
363 // [structural cycle]
364 f: (struct){
365 in: (number){ number }
366 out: (number){ number }
367 }
368 k00: (int){ 0 }
369 k10: (_|_){
370 // [structural cycle] in: structural cycle:
371 // ./x.cue:54:17
372 }
373 k20: (_|_){
374 // [structural cycle] in: structural cycle:
375 // ./x.cue:49:17
376 }
377 k30: (_|_){
378 // [structural cycle] in: structural cycle:
379 // ./x.cue:50:17
380 }
381 }
382 }
383 }
384}
385-- diff/-out/evalalpha<==>+out/eval --
386diff old new
387--- old
388+++ new
389@@ -2,11 +2,23 @@
390 structural cycle:
391 ./x.cue:6:9
392 structural cycle:
393+ ./x.cue:12:24
394+structural cycle:
395 ./x.cue:15:9
396 structural cycle:
397 ./x.cue:20:9
398 in: structural cycle:
399- ./x.cue:30:8
400+ ./x.cue:34:17
401+in: structural cycle:
402+ ./x.cue:35:17
403+in: structural cycle:
404+ ./x.cue:38:17
405+in: structural cycle:
406+ ./x.cue:49:17
407+in: structural cycle:
408+ ./x.cue:50:17
409+in: structural cycle:
410+ ./x.cue:54:17
411
412 Result:
413 (_|_){
414@@ -35,7 +47,7 @@
415 nn: (int){ int }
416 out: (_|_){
417 // [structural cycle] structural cycle:
418- // ./x.cue:15:9
419+ // ./x.cue:12:24
420 }
421 }
422 f: (_|_){
423@@ -72,26 +84,36 @@
424 k00: (int){ 0 }
425 k10: (_|_){
426 // [structural cycle] in: structural cycle:
427- // ./x.cue:30:8
428- }
429- k20: (_|_){
430- // [structural cycle] in: structural cycle:
431- // ./x.cue:30:8
432- }
433- k30: (_|_){
434- // [structural cycle] in: structural cycle:
435- // ./x.cue:30:8
436- }
437- }
438- ok1: (struct){
439+ // ./x.cue:38:17
440+ }
441+ k20: (_|_){
442+ // [structural cycle] in: structural cycle:
443+ // ./x.cue:34:17
444+ }
445+ k30: (_|_){
446+ // [structural cycle] in: structural cycle:
447+ // ./x.cue:35:17
448+ }
449+ }
450+ ok1: (_|_){
451+ // [structural cycle]
452 f: (struct){
453 in: (number){ number }
454 out: (number){ number }
455 }
456 k00: (int){ 0 }
457- k10: (int){ 0 }
458- k20: (int){ 0 }
459- k30: (int){ 0 }
460+ k10: (_|_){
461+ // [structural cycle] in: structural cycle:
462+ // ./x.cue:54:17
463+ }
464+ k20: (_|_){
465+ // [structural cycle] in: structural cycle:
466+ // ./x.cue:49:17
467+ }
468+ k30: (_|_){
469+ // [structural cycle] in: structural cycle:
470+ // ./x.cue:50:17
471+ }
472 }
473 }
474 }
475-- diff/todo/p2 --
476One test now fails. Given TODO, this may be okay.
477This does break Issue #2163.
View as plain text