...
1// Test various orders
2// https//cuelang.org/issues/2235
3
4-- reductions.cue --
5// Each of these tests triggers a slightly different path.
6
7t1: {
8 params: x.y
9 x: y: {}
10 for _ in x {
11 if true {
12 x: y: a: {}
13 }
14 }
15}
16
17t2: {
18 out: X.y
19 let X = m.x
20 m: x: y: {}
21 for v in m {
22 if true {
23 m: x: y: z: {}
24 }
25 }
26}
27
28t3: {
29 out: foo.bar
30
31 foo: bar: {}
32
33 for _ in foo {
34 for name, _ in foo {
35 foo: (name): _
36 }
37 }
38}
39
40-- issue2235.cue --
41package kubecluster
42
43import (
44 "strings"
45 "net"
46)
47
48shorewallParams: close({
49 [=~"^[A-Z0-9_]+$"]: [...net.IP]
50})
51
52#Cluster: {
53 clusterName: string
54 shorewallPrefix: "KUBERNETES_\(strings.ToUpper(clusterName))"
55}
56
57clusters: [CLUSTER=string]: #Cluster & {
58 clusterName: CLUSTER
59}
60
61#Cluster: {
62 globalIngressControllers: [string]: #GlobalIngressController
63 globalIngressControllers: admin: #GlobalIngressController & {
64 class: "admin"
65 }
66 for _, c in globalIngressControllers {
67 objects: c.objects
68 }
69}
70
71for clusterName, cluster in clusters {
72 for class, controller in cluster.globalIngressControllers {
73 let svc = controller.objects.namespaced.ingress.Service["\(class)-nginx-ingress-controller"]
74
75 shorewallParams: "\(cluster.shorewallPrefix)_INGRESS_\(strings.ToUpper(class))": svc.spec.externalIPs
76 }
77}
78
79#GlobalIngressController: {
80 class: string
81
82 objects: namespaced: ingress: {
83 Service: "\(class)-nginx-ingress-controller": {
84 spec: {
85 externalIPs: ["127.0.0.1"]
86 }
87 }
88 }
89
90 for kind, objs in objects.namespaced.ingress {
91 for name, obj in objs {
92 objects: namespaced: ingress: "\(kind)": "\(name)": metadata: labels: {
93 "ingress-class": class
94 stack: "ingress"
95 ...
96 }
97 }
98 }
99}
100
101clusters: foo: {}
102-- out/eval/stats --
103Leaks: 3
104Freed: 101
105Reused: 84
106Allocs: 20
107Retain: 72
108
109Unifications: 104
110Conjuncts: 271
111Disjuncts: 161
112-- out/evalalpha --
113(struct){
114 shorewallParams: (#struct){
115 KUBERNETES_FOO_INGRESS_ADMIN: (#list){
116 0: (string){ "127.0.0.1" }
117 }
118 }
119 #Cluster: (#struct){
120 clusterName: (string){ string }
121 shorewallPrefix: (_|_){
122 // [incomplete] #Cluster.shorewallPrefix: invalid interpolation: error in call to strings.ToUpper: non-concrete value string:
123 // ./issue2235.cue:14:19
124 // ./issue2235.cue:13:19
125 // ./issue2235.cue:14:33
126 }
127 globalIngressControllers: (#struct){
128 admin: (#struct){
129 class: (string){ "admin" }
130 objects: (#struct){
131 namespaced: (#struct){
132 ingress: (#struct){
133 Service: (#struct){
134 "admin-nginx-ingress-controller": (#struct){
135 spec: (#struct){
136 externalIPs: (#list){
137 0: (string){ "127.0.0.1" }
138 }
139 }
140 metadata: (#struct){
141 labels: (#struct){
142 "ingress-class": (string){ "admin" }
143 stack: (string){ "ingress" }
144 }
145 }
146 }
147 }
148 }
149 }
150 }
151 }
152 }
153 objects: (#struct){
154 namespaced: (#struct){
155 ingress: (#struct){
156 Service: (#struct){
157 "admin-nginx-ingress-controller": (#struct){
158 spec: (#struct){
159 externalIPs: (#list){
160 0: (string){ "127.0.0.1" }
161 }
162 }
163 metadata: (#struct){
164 labels: (#struct){
165 "ingress-class": (string){ "admin" }
166 stack: (string){ "ingress" }
167 }
168 }
169 }
170 }
171 }
172 }
173 }
174 }
175 clusters: (struct){
176 foo: (#struct){
177 clusterName: (string){ "foo" }
178 shorewallPrefix: (string){ "KUBERNETES_FOO" }
179 globalIngressControllers: (#struct){
180 admin: (#struct){
181 class: (string){ "admin" }
182 objects: (#struct){
183 namespaced: (#struct){
184 ingress: (#struct){
185 Service: (#struct){
186 "admin-nginx-ingress-controller": (#struct){
187 spec: (#struct){
188 externalIPs: (#list){
189 0: (string){ "127.0.0.1" }
190 }
191 }
192 metadata: (#struct){
193 labels: (#struct){
194 "ingress-class": (string){ "admin" }
195 stack: (string){ "ingress" }
196 }
197 }
198 }
199 }
200 }
201 }
202 }
203 }
204 }
205 objects: (#struct){
206 namespaced: (#struct){
207 ingress: (#struct){
208 Service: (#struct){
209 "admin-nginx-ingress-controller": (#struct){
210 spec: (#struct){
211 externalIPs: (#list){
212 0: (string){ "127.0.0.1" }
213 }
214 }
215 metadata: (#struct){
216 labels: (#struct){
217 "ingress-class": (string){ "admin" }
218 stack: (string){ "ingress" }
219 }
220 }
221 }
222 }
223 }
224 }
225 }
226 }
227 }
228 #GlobalIngressController: (_|_){
229 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: key value of dynamic field must be concrete, found _|_(invalid interpolation: #GlobalIngressController.objects.namespaced.ingress.Service: non-concrete value string (type string)):
230 // ./issue2235.cue:43:12
231 class: (string){ string }
232 objects: (#struct){
233 namespaced: (#struct){
234 ingress: (_|_){
235 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: key value of dynamic field must be concrete, found _|_(invalid interpolation: #GlobalIngressController.objects.namespaced.ingress.Service: non-concrete value string (type string)):
236 // ./issue2235.cue:43:12
237 Service: (_|_){
238 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: key value of dynamic field must be concrete, found _|_(invalid interpolation: #GlobalIngressController.objects.namespaced.ingress.Service: non-concrete value string (type string)):
239 // ./issue2235.cue:43:12
240 }
241 }
242 }
243 }
244 }
245 t1: (struct){
246 params: (struct){
247 a: (struct){
248 }
249 }
250 x: (struct){
251 y: (struct){
252 a: (struct){
253 }
254 }
255 }
256 }
257 t2: (struct){
258 out: (struct){
259 z: (struct){
260 }
261 }
262 let X#2 = (struct){
263 y: (struct){
264 z: (struct){
265 }
266 }
267 }
268 m: (struct){
269 x: (struct){
270 y: (struct){
271 z: (struct){
272 }
273 }
274 }
275 }
276 }
277 t3: (struct){
278 out: (struct){
279 }
280 foo: (struct){
281 bar: (struct){
282 }
283 }
284 }
285 let svc#1multi = &[&[&[&[&[〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"]]]]]]
286}
287-- diff/-out/evalalpha<==>+out/eval --
288diff old new
289--- old
290+++ new
291@@ -114,20 +114,17 @@
292 }
293 }
294 #GlobalIngressController: (_|_){
295- // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string):
296+ // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: key value of dynamic field must be concrete, found _|_(invalid interpolation: #GlobalIngressController.objects.namespaced.ingress.Service: non-concrete value string (type string)):
297 // ./issue2235.cue:43:12
298- // ./issue2235.cue:40:9
299 class: (string){ string }
300 objects: (#struct){
301 namespaced: (#struct){
302 ingress: (_|_){
303- // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string):
304+ // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: key value of dynamic field must be concrete, found _|_(invalid interpolation: #GlobalIngressController.objects.namespaced.ingress.Service: non-concrete value string (type string)):
305 // ./issue2235.cue:43:12
306- // ./issue2235.cue:40:9
307 Service: (_|_){
308- // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string):
309+ // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: key value of dynamic field must be concrete, found _|_(invalid interpolation: #GlobalIngressController.objects.namespaced.ingress.Service: non-concrete value string (type string)):
310 // ./issue2235.cue:43:12
311- // ./issue2235.cue:40:9
312 }
313 }
314 }
315@@ -173,5 +170,5 @@
316 }
317 }
318 }
319- let svc#1multi = 〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"]
320+ let svc#1multi = &[&[&[&[&[〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"]]]]]]
321 }
322-- diff/todo/p2 --
323Different, but okay, error message, but missing some positions
324-- out/eval --
325(struct){
326 shorewallParams: (#struct){
327 KUBERNETES_FOO_INGRESS_ADMIN: (#list){
328 0: (string){ "127.0.0.1" }
329 }
330 }
331 #Cluster: (#struct){
332 clusterName: (string){ string }
333 shorewallPrefix: (_|_){
334 // [incomplete] #Cluster.shorewallPrefix: invalid interpolation: error in call to strings.ToUpper: non-concrete value string:
335 // ./issue2235.cue:14:19
336 // ./issue2235.cue:13:19
337 // ./issue2235.cue:14:33
338 }
339 globalIngressControllers: (#struct){
340 admin: (#struct){
341 class: (string){ "admin" }
342 objects: (#struct){
343 namespaced: (#struct){
344 ingress: (#struct){
345 Service: (#struct){
346 "admin-nginx-ingress-controller": (#struct){
347 spec: (#struct){
348 externalIPs: (#list){
349 0: (string){ "127.0.0.1" }
350 }
351 }
352 metadata: (#struct){
353 labels: (#struct){
354 "ingress-class": (string){ "admin" }
355 stack: (string){ "ingress" }
356 }
357 }
358 }
359 }
360 }
361 }
362 }
363 }
364 }
365 objects: (#struct){
366 namespaced: (#struct){
367 ingress: (#struct){
368 Service: (#struct){
369 "admin-nginx-ingress-controller": (#struct){
370 spec: (#struct){
371 externalIPs: (#list){
372 0: (string){ "127.0.0.1" }
373 }
374 }
375 metadata: (#struct){
376 labels: (#struct){
377 "ingress-class": (string){ "admin" }
378 stack: (string){ "ingress" }
379 }
380 }
381 }
382 }
383 }
384 }
385 }
386 }
387 clusters: (struct){
388 foo: (#struct){
389 clusterName: (string){ "foo" }
390 shorewallPrefix: (string){ "KUBERNETES_FOO" }
391 globalIngressControllers: (#struct){
392 admin: (#struct){
393 class: (string){ "admin" }
394 objects: (#struct){
395 namespaced: (#struct){
396 ingress: (#struct){
397 Service: (#struct){
398 "admin-nginx-ingress-controller": (#struct){
399 spec: (#struct){
400 externalIPs: (#list){
401 0: (string){ "127.0.0.1" }
402 }
403 }
404 metadata: (#struct){
405 labels: (#struct){
406 "ingress-class": (string){ "admin" }
407 stack: (string){ "ingress" }
408 }
409 }
410 }
411 }
412 }
413 }
414 }
415 }
416 }
417 objects: (#struct){
418 namespaced: (#struct){
419 ingress: (#struct){
420 Service: (#struct){
421 "admin-nginx-ingress-controller": (#struct){
422 spec: (#struct){
423 externalIPs: (#list){
424 0: (string){ "127.0.0.1" }
425 }
426 }
427 metadata: (#struct){
428 labels: (#struct){
429 "ingress-class": (string){ "admin" }
430 stack: (string){ "ingress" }
431 }
432 }
433 }
434 }
435 }
436 }
437 }
438 }
439 }
440 #GlobalIngressController: (_|_){
441 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string):
442 // ./issue2235.cue:43:12
443 // ./issue2235.cue:40:9
444 class: (string){ string }
445 objects: (#struct){
446 namespaced: (#struct){
447 ingress: (_|_){
448 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string):
449 // ./issue2235.cue:43:12
450 // ./issue2235.cue:40:9
451 Service: (_|_){
452 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string):
453 // ./issue2235.cue:43:12
454 // ./issue2235.cue:40:9
455 }
456 }
457 }
458 }
459 }
460 t1: (struct){
461 params: (struct){
462 a: (struct){
463 }
464 }
465 x: (struct){
466 y: (struct){
467 a: (struct){
468 }
469 }
470 }
471 }
472 t2: (struct){
473 out: (struct){
474 z: (struct){
475 }
476 }
477 let X#2 = (struct){
478 y: (struct){
479 z: (struct){
480 }
481 }
482 }
483 m: (struct){
484 x: (struct){
485 y: (struct){
486 z: (struct){
487 }
488 }
489 }
490 }
491 }
492 t3: (struct){
493 out: (struct){
494 }
495 foo: (struct){
496 bar: (struct){
497 }
498 }
499 }
500 let svc#1multi = 〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"]
501}
502-- out/compile --
503--- issue2235.cue
504{
505 shorewallParams: close({
506 [=~"^[A-Z0-9_]+$"]: [
507 ...〈import;net〉.IP,
508 ]
509 })
510 #Cluster: {
511 clusterName: string
512 shorewallPrefix: "KUBERNETES_\(〈import;strings〉.ToUpper(〈0;clusterName〉))"
513 }
514 clusters: {
515 [string]: (〈1;#Cluster〉 & {
516 clusterName: 〈1;-〉
517 })
518 }
519 #Cluster: {
520 globalIngressControllers: {
521 [string]: 〈2;#GlobalIngressController〉
522 }
523 globalIngressControllers: {
524 admin: (〈2;#GlobalIngressController〉 & {
525 class: "admin"
526 })
527 }
528 for _, c in 〈0;globalIngressControllers〉 {
529 objects: 〈1;c〉.objects
530 }
531 }
532 for clusterName, cluster in 〈0;clusters〉 {
533 for class, controller in 〈1;cluster〉.globalIngressControllers {
534 let svc#1multi = 〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"]
535 shorewallParams: {
536 "\(〈4;cluster〉.shorewallPrefix)_INGRESS_\(〈import;strings〉.ToUpper(〈2;class〉))": 〈1;let svc#1〉.spec.externalIPs
537 }
538 }
539 }
540 #GlobalIngressController: {
541 class: string
542 objects: {
543 namespaced: {
544 ingress: {
545 Service: {
546 "\(〈4;class〉)-nginx-ingress-controller": {
547 spec: {
548 externalIPs: [
549 "127.0.0.1",
550 ]
551 }
552 }
553 }
554 }
555 }
556 }
557 for kind, objs in 〈0;objects〉.namespaced.ingress {
558 for name, obj in 〈1;objs〉 {
559 objects: {
560 namespaced: {
561 ingress: {
562 "\(〈6;kind〉)": {
563 "\(〈5;name〉)": {
564 metadata: {
565 labels: {
566 "ingress-class": 〈11;class〉
567 stack: "ingress"
568 ...
569 }
570 }
571 }
572 }
573 }
574 }
575 }
576 }
577 }
578 }
579 clusters: {
580 foo: {}
581 }
582}
583--- reductions.cue
584{
585 t1: {
586 params: 〈0;x〉.y
587 x: {
588 y: {}
589 }
590 for _, _ in 〈0;x〉 {
591 if true {
592 x: {
593 y: {
594 a: {}
595 }
596 }
597 }
598 }
599 }
600 t2: {
601 out: 〈0;let X#2〉.y
602 let X#2 = 〈0;m〉.x
603 m: {
604 x: {
605 y: {}
606 }
607 }
608 for _, v in 〈0;m〉 {
609 if true {
610 m: {
611 x: {
612 y: {
613 z: {}
614 }
615 }
616 }
617 }
618 }
619 }
620 t3: {
621 out: 〈0;foo〉.bar
622 foo: {
623 bar: {}
624 }
625 for _, _ in 〈0;foo〉 {
626 for name, _ in 〈2;foo〉 {
627 foo: {
628 〈2;name〉: _
629 }
630 }
631 }
632 }
633}
View as plain text