cuelang.org/go@v0.10.1/cue/testdata/eval/issue2235.txtar (about) 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 7 t1: { 8 params: x.y 9 x: y: {} 10 for _ in x { 11 if true { 12 x: y: a: {} 13 } 14 } 15 } 16 17 t2: { 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 28 t3: { 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 -- 41 package kubecluster 42 43 import ( 44 "strings" 45 "net" 46 ) 47 48 shorewallParams: close({ 49 [=~"^[A-Z0-9_]+$"]: [...net.IP] 50 }) 51 52 #Cluster: { 53 clusterName: string 54 shorewallPrefix: "KUBERNETES_\(strings.ToUpper(clusterName))" 55 } 56 57 clusters: [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 71 for 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 101 clusters: foo: {} 102 -- out/eval/stats -- 103 Leaks: 3 104 Freed: 101 105 Reused: 84 106 Allocs: 20 107 Retain: 72 108 109 Unifications: 104 110 Conjuncts: 271 111 Disjuncts: 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 -- 288 diff 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 -- diff/todo/p2 -- 316 Different, but okay, error message, but missing some positions 317 -- out/eval -- 318 (struct){ 319 shorewallParams: (#struct){ 320 KUBERNETES_FOO_INGRESS_ADMIN: (#list){ 321 0: (string){ "127.0.0.1" } 322 } 323 } 324 #Cluster: (#struct){ 325 clusterName: (string){ string } 326 shorewallPrefix: (_|_){ 327 // [incomplete] #Cluster.shorewallPrefix: invalid interpolation: error in call to strings.ToUpper: non-concrete value string: 328 // ./issue2235.cue:14:19 329 // ./issue2235.cue:13:19 330 // ./issue2235.cue:14:33 331 } 332 globalIngressControllers: (#struct){ 333 admin: (#struct){ 334 class: (string){ "admin" } 335 objects: (#struct){ 336 namespaced: (#struct){ 337 ingress: (#struct){ 338 Service: (#struct){ 339 "admin-nginx-ingress-controller": (#struct){ 340 spec: (#struct){ 341 externalIPs: (#list){ 342 0: (string){ "127.0.0.1" } 343 } 344 } 345 metadata: (#struct){ 346 labels: (#struct){ 347 "ingress-class": (string){ "admin" } 348 stack: (string){ "ingress" } 349 } 350 } 351 } 352 } 353 } 354 } 355 } 356 } 357 } 358 objects: (#struct){ 359 namespaced: (#struct){ 360 ingress: (#struct){ 361 Service: (#struct){ 362 "admin-nginx-ingress-controller": (#struct){ 363 spec: (#struct){ 364 externalIPs: (#list){ 365 0: (string){ "127.0.0.1" } 366 } 367 } 368 metadata: (#struct){ 369 labels: (#struct){ 370 "ingress-class": (string){ "admin" } 371 stack: (string){ "ingress" } 372 } 373 } 374 } 375 } 376 } 377 } 378 } 379 } 380 clusters: (struct){ 381 foo: (#struct){ 382 clusterName: (string){ "foo" } 383 shorewallPrefix: (string){ "KUBERNETES_FOO" } 384 globalIngressControllers: (#struct){ 385 admin: (#struct){ 386 class: (string){ "admin" } 387 objects: (#struct){ 388 namespaced: (#struct){ 389 ingress: (#struct){ 390 Service: (#struct){ 391 "admin-nginx-ingress-controller": (#struct){ 392 spec: (#struct){ 393 externalIPs: (#list){ 394 0: (string){ "127.0.0.1" } 395 } 396 } 397 metadata: (#struct){ 398 labels: (#struct){ 399 "ingress-class": (string){ "admin" } 400 stack: (string){ "ingress" } 401 } 402 } 403 } 404 } 405 } 406 } 407 } 408 } 409 } 410 objects: (#struct){ 411 namespaced: (#struct){ 412 ingress: (#struct){ 413 Service: (#struct){ 414 "admin-nginx-ingress-controller": (#struct){ 415 spec: (#struct){ 416 externalIPs: (#list){ 417 0: (string){ "127.0.0.1" } 418 } 419 } 420 metadata: (#struct){ 421 labels: (#struct){ 422 "ingress-class": (string){ "admin" } 423 stack: (string){ "ingress" } 424 } 425 } 426 } 427 } 428 } 429 } 430 } 431 } 432 } 433 #GlobalIngressController: (_|_){ 434 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string): 435 // ./issue2235.cue:43:12 436 // ./issue2235.cue:40:9 437 class: (string){ string } 438 objects: (#struct){ 439 namespaced: (#struct){ 440 ingress: (_|_){ 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 Service: (_|_){ 445 // [incomplete] #GlobalIngressController.objects.namespaced.ingress.Service: invalid interpolation: non-concrete value string (type string): 446 // ./issue2235.cue:43:12 447 // ./issue2235.cue:40:9 448 } 449 } 450 } 451 } 452 } 453 t1: (struct){ 454 params: (struct){ 455 a: (struct){ 456 } 457 } 458 x: (struct){ 459 y: (struct){ 460 a: (struct){ 461 } 462 } 463 } 464 } 465 t2: (struct){ 466 out: (struct){ 467 z: (struct){ 468 } 469 } 470 let X#2 = (struct){ 471 y: (struct){ 472 z: (struct){ 473 } 474 } 475 } 476 m: (struct){ 477 x: (struct){ 478 y: (struct){ 479 z: (struct){ 480 } 481 } 482 } 483 } 484 } 485 t3: (struct){ 486 out: (struct){ 487 } 488 foo: (struct){ 489 bar: (struct){ 490 } 491 } 492 } 493 let svc#1multi = 〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"] 494 } 495 -- out/compile -- 496 --- issue2235.cue 497 { 498 shorewallParams: close({ 499 [=~"^[A-Z0-9_]+$"]: [ 500 ...〈import;net〉.IP, 501 ] 502 }) 503 #Cluster: { 504 clusterName: string 505 shorewallPrefix: "KUBERNETES_\(〈import;strings〉.ToUpper(〈0;clusterName〉))" 506 } 507 clusters: { 508 [string]: (〈1;#Cluster〉 & { 509 clusterName: 〈1;-〉 510 }) 511 } 512 #Cluster: { 513 globalIngressControllers: { 514 [string]: 〈2;#GlobalIngressController〉 515 } 516 globalIngressControllers: { 517 admin: (〈2;#GlobalIngressController〉 & { 518 class: "admin" 519 }) 520 } 521 for _, c in 〈0;globalIngressControllers〉 { 522 objects: 〈1;c〉.objects 523 } 524 } 525 for clusterName, cluster in 〈0;clusters〉 { 526 for class, controller in 〈1;cluster〉.globalIngressControllers { 527 let svc#1multi = 〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"] 528 shorewallParams: { 529 "\(〈4;cluster〉.shorewallPrefix)_INGRESS_\(〈import;strings〉.ToUpper(〈2;class〉))": 〈1;let svc#1〉.spec.externalIPs 530 } 531 } 532 } 533 #GlobalIngressController: { 534 class: string 535 objects: { 536 namespaced: { 537 ingress: { 538 Service: { 539 "\(〈4;class〉)-nginx-ingress-controller": { 540 spec: { 541 externalIPs: [ 542 "127.0.0.1", 543 ] 544 } 545 } 546 } 547 } 548 } 549 } 550 for kind, objs in 〈0;objects〉.namespaced.ingress { 551 for name, obj in 〈1;objs〉 { 552 objects: { 553 namespaced: { 554 ingress: { 555 "\(〈6;kind〉)": { 556 "\(〈5;name〉)": { 557 metadata: { 558 labels: { 559 "ingress-class": 〈11;class〉 560 stack: "ingress" 561 ... 562 } 563 } 564 } 565 } 566 } 567 } 568 } 569 } 570 } 571 } 572 clusters: { 573 foo: {} 574 } 575 } 576 --- reductions.cue 577 { 578 t1: { 579 params: 〈0;x〉.y 580 x: { 581 y: {} 582 } 583 for _, _ in 〈0;x〉 { 584 if true { 585 x: { 586 y: { 587 a: {} 588 } 589 } 590 } 591 } 592 } 593 t2: { 594 out: 〈0;let X#2〉.y 595 let X#2 = 〈0;m〉.x 596 m: { 597 x: { 598 y: {} 599 } 600 } 601 for _, v in 〈0;m〉 { 602 if true { 603 m: { 604 x: { 605 y: { 606 z: {} 607 } 608 } 609 } 610 } 611 } 612 } 613 t3: { 614 out: 〈0;foo〉.bar 615 foo: { 616 bar: {} 617 } 618 for _, _ in 〈0;foo〉 { 619 for name, _ in 〈2;foo〉 { 620 foo: { 621 〈2;name〉: _ 622 } 623 } 624 } 625 } 626 }