cuelang.org/go@v0.13.0/cue/testdata/eval/issue3801.txtar (about) 1 # This issue addresses evaluation in nested lets. 2 -- nested.cue -- 3 issue3801: let: reduced: { 4 let F = { 5 base: { 6 in: string 7 let X = {a: "\(in)" }.a 8 out: X 9 } 10 XXX: base & {in: "foo"} // failure is here 11 } 12 z: F.XXX.out 13 } 14 issue3801: nonRooted: reduced: { 15 #Output: output: { 16 #base: { 17 val0: string 18 msgObj: {a: val0}.a 19 value: msgObj 20 } 21 out: #base & {val0: "foo"} 22 } 23 out: (#Output & {}).output // non-concrete 24 } 25 issue3801: let: full: { 26 #Resource: { 27 someMsg: string 28 obs: {} | *{missing: true} 29 30 let pickMsg = [ 31 if obs.missing {msg: "\(someMsg)"}, 32 {msg: "bar"}, 33 ][0] 34 patches: [{ 35 op: "add" 36 path: "/metadata" 37 value: pickMsg.msg 38 }] 39 } 40 41 #Patches: [string]: _ 42 #JSONPatch: { 43 namespace?: string 44 patch: [...#JSONOp] 45 output: #Patches & {(namespace): patch} 46 } 47 #JSONOp: { 48 op: "add" 49 path: string 50 value: _ 51 } | { 52 op: "remove" 53 path: string 54 } 55 56 #Main: { 57 NS=namespace: string 58 59 output: jsonPatch.output 60 61 let jsonPatch = #JSONPatch & { 62 let base = #Resource & {} 63 let withMsg = base & {someMsg: "foo"} 64 65 namespace: NS 66 67 patch: withMsg.patches 68 } 69 } 70 out: (#Main & {namespace: "ns1"}).output 71 } 72 issue3801: nonRooted: full: { 73 #Output: { 74 NS=namespace: string 75 output: (#SubOutput & { 76 namespace: NS 77 let base2 = { 78 let base = #Base & {} 79 output: base & {val0: "foo"} 80 } 81 patch: base2.output.value 82 }).output 83 } 84 out: (#Output & {namespace: "ns1"}).output 85 86 #SubOutput: { 87 namespace?: string 88 89 patch: _ 90 output: (namespace): patch 91 } 92 93 #Base: { 94 val0: string 95 let msgObj = [val0][0] 96 value: msgObj 97 } 98 } 99 -- out/evalalpha/stats -- 100 Leaks: 266 101 Freed: 0 102 Reused: 0 103 Allocs: 266 104 Retain: 0 105 106 Unifications: 181 107 Conjuncts: 346 108 Disjuncts: 16 109 110 CloseIDElems: 151 111 NumCloseIDs: 83 112 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 113 diff old new 114 --- old 115 +++ new 116 @@ -1,9 +1,12 @@ 117 -Leaks: 237 118 -Freed: 408 119 -Reused: 402 120 -Allocs: 243 121 -Retain: 430 122 - 123 -Unifications: 599 124 -Conjuncts: 1319 125 -Disjuncts: 762 126 +Leaks: 266 127 +Freed: 0 128 +Reused: 0 129 +Allocs: 266 130 +Retain: 0 131 + 132 +Unifications: 181 133 +Conjuncts: 346 134 +Disjuncts: 16 135 + 136 +CloseIDElems: 151 137 +NumCloseIDs: 83 138 -- out/eval/stats -- 139 Leaks: 237 140 Freed: 408 141 Reused: 402 142 Allocs: 243 143 Retain: 430 144 145 Unifications: 599 146 Conjuncts: 1319 147 Disjuncts: 762 148 -- out/evalalpha -- 149 (struct){ 150 issue3801: (struct){ 151 let: (struct){ 152 reduced: (struct){ 153 let F#1 = (struct){ 154 base: (struct){ 155 in: (string){ string } 156 let X#2 = (_|_){ 157 // [incomplete] issue3801.let.reduced.F.base.X: invalid interpolation: non-concrete value string (type string): 158 // ./nested.cue:5:16 159 // ./nested.cue:4:8 160 } 161 out: (_|_){ 162 // [incomplete] issue3801.let.reduced.F.base.out: invalid interpolation: non-concrete value string (type string): 163 // ./nested.cue:5:16 164 // ./nested.cue:4:8 165 } 166 } 167 XXX: (struct){ 168 in: (string){ "foo" } 169 let X#2 = (string){ "foo" } 170 out: (string){ "foo" } 171 } 172 } 173 z: (string){ "foo" } 174 } 175 full: (struct){ 176 #Resource: (#struct){ 177 someMsg: (string){ string } 178 obs: (#struct){ |(*(#struct){ 179 missing: (bool){ true } 180 }, (#struct){ 181 }) } 182 let pickMsg#4 = (#struct){ 183 msg: (_|_){ 184 // [incomplete] issue3801.let.full.#Resource.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 185 // ./nested.cue:29:25 186 // ./nested.cue:25:12 187 } 188 } 189 patches: (#list){ 190 0: (#struct){ 191 op: (string){ "add" } 192 path: (string){ "/metadata" } 193 value: (_|_){ 194 // [incomplete] issue3801.let.full.#Resource.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 195 // ./nested.cue:29:25 196 // ./nested.cue:25:12 197 } 198 } 199 } 200 } 201 #Patches: (#struct){ 202 } 203 #JSONPatch: (#struct){ 204 namespace?: (string){ string } 205 patch: (list){ 206 } 207 output: (_|_){ 208 // [incomplete] issue3801.let.full.#JSONPatch.output: cannot reference optional field: namespace: 209 // ./nested.cue:43:24 210 } 211 } 212 #JSONOp: (#struct){ |((#struct){ 213 op: (string){ "add" } 214 path: (string){ string } 215 value: (_){ _ } 216 }, (#struct){ 217 op: (string){ "remove" } 218 path: (string){ string } 219 }) } 220 #Main: (#struct){ 221 namespace: (string){ string } 222 output: (_|_){ 223 // [incomplete] issue3801.let.full.#Main.jsonPatch.output: key value of dynamic field must be concrete, found string: 224 // ./nested.cue:43:24 225 // ./nested.cue:41:15 226 } 227 let jsonPatch#5 = (#struct){ 228 let base#8 = (#struct){ 229 someMsg: (string){ string } 230 obs: (#struct){ |(*(#struct){ 231 missing: (bool){ true } 232 }, (#struct){ 233 }) } 234 let pickMsg#4 = (#struct){ 235 msg: (_|_){ 236 // [incomplete] issue3801.let.full.#Main.jsonPatch.base.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 237 // ./nested.cue:29:25 238 // ./nested.cue:25:12 239 } 240 } 241 patches: (#list){ 242 0: (#struct){ 243 op: (string){ "add" } 244 path: (string){ "/metadata" } 245 value: (_|_){ 246 // [incomplete] issue3801.let.full.#Main.jsonPatch.base.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 247 // ./nested.cue:29:25 248 // ./nested.cue:25:12 249 } 250 } 251 } 252 } 253 let withMsg#9 = (#struct){ 254 someMsg: (string){ "foo" } 255 obs: (#struct){ |(*(#struct){ 256 missing: (bool){ true } 257 }, (#struct){ 258 }) } 259 let pickMsg#4 = (#struct){ 260 msg: (string){ "foo" } 261 } 262 patches: (#list){ 263 0: (#struct){ 264 op: (string){ "add" } 265 path: (string){ "/metadata" } 266 value: (string){ "foo" } 267 } 268 } 269 } 270 namespace: (string){ string } 271 patch: (#list){ 272 0: (#struct){ 273 op: (string){ "add" } 274 path: (string){ "/metadata" } 275 value: (string){ "foo" } 276 } 277 } 278 output: (_|_){ 279 // [incomplete] issue3801.let.full.#Main.jsonPatch.output: key value of dynamic field must be concrete, found string: 280 // ./nested.cue:43:24 281 // ./nested.cue:41:15 282 } 283 } 284 } 285 out: (#struct){ 286 ns1: (#list){ 287 0: (#struct){ 288 op: (string){ "add" } 289 path: (string){ "/metadata" } 290 value: (string){ "foo" } 291 } 292 } 293 } 294 } 295 } 296 nonRooted: (struct){ 297 reduced: (struct){ 298 #Output: (#struct){ 299 output: (#struct){ 300 #base: (#struct){ 301 val0: (string){ string } 302 msgObj: (string){ string } 303 value: (string){ string } 304 } 305 out: (#struct){ 306 val0: (string){ "foo" } 307 msgObj: (string){ "foo" } 308 value: (string){ "foo" } 309 } 310 } 311 } 312 out: (#struct){ 313 #base: (#struct){ 314 val0: (string){ string } 315 msgObj: (string){ string } 316 value: (string){ string } 317 } 318 out: (#struct){ 319 val0: (string){ "foo" } 320 msgObj: (string){ "foo" } 321 value: (string){ "foo" } 322 } 323 } 324 } 325 full: (struct){ 326 #Output: (#struct){ 327 namespace: (string){ string } 328 output: (_|_){ 329 // [incomplete] issue3801.nonRooted.full.#Output.output: key value of dynamic field must be concrete, found string: 330 // ./nested.cue:88:12 331 // ./nested.cue:85:15 332 } 333 } 334 out: (#struct){ 335 ns1: (string){ "foo" } 336 } 337 #SubOutput: (#struct){ 338 namespace?: (string){ string } 339 patch: (_){ _ } 340 output: (_|_){ 341 // [incomplete] issue3801.nonRooted.full.#SubOutput.output: cannot reference optional field: namespace: 342 // ./nested.cue:88:12 343 } 344 } 345 #Base: (#struct){ 346 val0: (string){ string } 347 let msgObj#D = (string){ string } 348 value: (string){ string } 349 } 350 } 351 } 352 } 353 } 354 -- diff/-out/evalalpha<==>+out/eval -- 355 diff old new 356 --- old 357 +++ new 358 @@ -43,7 +43,7 @@ 359 op: (string){ "add" } 360 path: (string){ "/metadata" } 361 value: (_|_){ 362 - // [incomplete] issue3801.let.full.#Resource.patches.0.value: invalid interpolation: non-concrete value string (type string): 363 + // [incomplete] issue3801.let.full.#Resource.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 364 // ./nested.cue:29:25 365 // ./nested.cue:25:12 366 } 367 @@ -72,38 +72,11 @@ 368 #Main: (#struct){ 369 namespace: (string){ string } 370 output: (_|_){ 371 - // [incomplete] issue3801.let.full.#Main.output: invalid non-ground value string (must be concrete string): 372 + // [incomplete] issue3801.let.full.#Main.jsonPatch.output: key value of dynamic field must be concrete, found string: 373 + // ./nested.cue:43:24 374 // ./nested.cue:41:15 375 - // ./nested.cue:63:15 376 - _: (#list){ 377 - 0: (#struct){ 378 - op: (string){ "add" } 379 - path: (string){ "/metadata" } 380 - value: (string){ "foo" } 381 - } 382 - } 383 } 384 let jsonPatch#5 = (#struct){ 385 - namespace: (string){ string } 386 - patch: (#list){ 387 - 0: (#struct){ 388 - op: (string){ "add" } 389 - path: (string){ "/metadata" } 390 - value: (string){ "foo" } 391 - } 392 - } 393 - output: (_|_){ 394 - // [incomplete] issue3801.let.full.#Main.jsonPatch.output: invalid non-ground value string (must be concrete string): 395 - // ./nested.cue:41:15 396 - // ./nested.cue:63:15 397 - _: (#list){ 398 - 0: (#struct){ 399 - op: (string){ "add" } 400 - path: (string){ "/metadata" } 401 - value: (string){ "foo" } 402 - } 403 - } 404 - } 405 let base#8 = (#struct){ 406 someMsg: (string){ string } 407 obs: (#struct){ |(*(#struct){ 408 @@ -122,7 +95,7 @@ 409 op: (string){ "add" } 410 path: (string){ "/metadata" } 411 value: (_|_){ 412 - // [incomplete] issue3801.let.full.#Main.jsonPatch.base.patches.0.value: invalid interpolation: non-concrete value string (type string): 413 + // [incomplete] issue3801.let.full.#Main.jsonPatch.base.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 414 // ./nested.cue:29:25 415 // ./nested.cue:25:12 416 } 417 @@ -146,6 +119,19 @@ 418 } 419 } 420 } 421 + namespace: (string){ string } 422 + patch: (#list){ 423 + 0: (#struct){ 424 + op: (string){ "add" } 425 + path: (string){ "/metadata" } 426 + value: (string){ "foo" } 427 + } 428 + } 429 + output: (_|_){ 430 + // [incomplete] issue3801.let.full.#Main.jsonPatch.output: key value of dynamic field must be concrete, found string: 431 + // ./nested.cue:43:24 432 + // ./nested.cue:41:15 433 + } 434 } 435 } 436 out: (#struct){ 437 @@ -175,7 +161,7 @@ 438 } 439 } 440 } 441 - out: (struct){ 442 + out: (#struct){ 443 #base: (#struct){ 444 val0: (string){ string } 445 msgObj: (string){ string } 446 @@ -192,13 +178,12 @@ 447 #Output: (#struct){ 448 namespace: (string){ string } 449 output: (_|_){ 450 - // [incomplete] issue3801.nonRooted.full.#Output.output: invalid non-ground value string (must be concrete string): 451 + // [incomplete] issue3801.nonRooted.full.#Output.output: key value of dynamic field must be concrete, found string: 452 + // ./nested.cue:88:12 453 // ./nested.cue:85:15 454 - // ./nested.cue:74:15 455 - _: (string){ "foo" } 456 - } 457 - } 458 - out: (struct){ 459 + } 460 + } 461 + out: (#struct){ 462 ns1: (string){ "foo" } 463 } 464 #SubOutput: (#struct){ 465 -- out/eval -- 466 (struct){ 467 issue3801: (struct){ 468 let: (struct){ 469 reduced: (struct){ 470 let F#1 = (struct){ 471 base: (struct){ 472 in: (string){ string } 473 let X#2 = (_|_){ 474 // [incomplete] issue3801.let.reduced.F.base.X: invalid interpolation: non-concrete value string (type string): 475 // ./nested.cue:5:16 476 // ./nested.cue:4:8 477 } 478 out: (_|_){ 479 // [incomplete] issue3801.let.reduced.F.base.out: invalid interpolation: non-concrete value string (type string): 480 // ./nested.cue:5:16 481 // ./nested.cue:4:8 482 } 483 } 484 XXX: (struct){ 485 in: (string){ "foo" } 486 let X#2 = (string){ "foo" } 487 out: (string){ "foo" } 488 } 489 } 490 z: (string){ "foo" } 491 } 492 full: (struct){ 493 #Resource: (#struct){ 494 someMsg: (string){ string } 495 obs: (#struct){ |(*(#struct){ 496 missing: (bool){ true } 497 }, (#struct){ 498 }) } 499 let pickMsg#4 = (#struct){ 500 msg: (_|_){ 501 // [incomplete] issue3801.let.full.#Resource.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 502 // ./nested.cue:29:25 503 // ./nested.cue:25:12 504 } 505 } 506 patches: (#list){ 507 0: (#struct){ 508 op: (string){ "add" } 509 path: (string){ "/metadata" } 510 value: (_|_){ 511 // [incomplete] issue3801.let.full.#Resource.patches.0.value: invalid interpolation: non-concrete value string (type string): 512 // ./nested.cue:29:25 513 // ./nested.cue:25:12 514 } 515 } 516 } 517 } 518 #Patches: (#struct){ 519 } 520 #JSONPatch: (#struct){ 521 namespace?: (string){ string } 522 patch: (list){ 523 } 524 output: (_|_){ 525 // [incomplete] issue3801.let.full.#JSONPatch.output: cannot reference optional field: namespace: 526 // ./nested.cue:43:24 527 } 528 } 529 #JSONOp: (#struct){ |((#struct){ 530 op: (string){ "add" } 531 path: (string){ string } 532 value: (_){ _ } 533 }, (#struct){ 534 op: (string){ "remove" } 535 path: (string){ string } 536 }) } 537 #Main: (#struct){ 538 namespace: (string){ string } 539 output: (_|_){ 540 // [incomplete] issue3801.let.full.#Main.output: invalid non-ground value string (must be concrete string): 541 // ./nested.cue:41:15 542 // ./nested.cue:63:15 543 _: (#list){ 544 0: (#struct){ 545 op: (string){ "add" } 546 path: (string){ "/metadata" } 547 value: (string){ "foo" } 548 } 549 } 550 } 551 let jsonPatch#5 = (#struct){ 552 namespace: (string){ string } 553 patch: (#list){ 554 0: (#struct){ 555 op: (string){ "add" } 556 path: (string){ "/metadata" } 557 value: (string){ "foo" } 558 } 559 } 560 output: (_|_){ 561 // [incomplete] issue3801.let.full.#Main.jsonPatch.output: invalid non-ground value string (must be concrete string): 562 // ./nested.cue:41:15 563 // ./nested.cue:63:15 564 _: (#list){ 565 0: (#struct){ 566 op: (string){ "add" } 567 path: (string){ "/metadata" } 568 value: (string){ "foo" } 569 } 570 } 571 } 572 let base#8 = (#struct){ 573 someMsg: (string){ string } 574 obs: (#struct){ |(*(#struct){ 575 missing: (bool){ true } 576 }, (#struct){ 577 }) } 578 let pickMsg#4 = (#struct){ 579 msg: (_|_){ 580 // [incomplete] issue3801.let.full.#Main.jsonPatch.base.pickMsg.msg: invalid interpolation: non-concrete value string (type string): 581 // ./nested.cue:29:25 582 // ./nested.cue:25:12 583 } 584 } 585 patches: (#list){ 586 0: (#struct){ 587 op: (string){ "add" } 588 path: (string){ "/metadata" } 589 value: (_|_){ 590 // [incomplete] issue3801.let.full.#Main.jsonPatch.base.patches.0.value: invalid interpolation: non-concrete value string (type string): 591 // ./nested.cue:29:25 592 // ./nested.cue:25:12 593 } 594 } 595 } 596 } 597 let withMsg#9 = (#struct){ 598 someMsg: (string){ "foo" } 599 obs: (#struct){ |(*(#struct){ 600 missing: (bool){ true } 601 }, (#struct){ 602 }) } 603 let pickMsg#4 = (#struct){ 604 msg: (string){ "foo" } 605 } 606 patches: (#list){ 607 0: (#struct){ 608 op: (string){ "add" } 609 path: (string){ "/metadata" } 610 value: (string){ "foo" } 611 } 612 } 613 } 614 } 615 } 616 out: (#struct){ 617 ns1: (#list){ 618 0: (#struct){ 619 op: (string){ "add" } 620 path: (string){ "/metadata" } 621 value: (string){ "foo" } 622 } 623 } 624 } 625 } 626 } 627 nonRooted: (struct){ 628 reduced: (struct){ 629 #Output: (#struct){ 630 output: (#struct){ 631 #base: (#struct){ 632 val0: (string){ string } 633 msgObj: (string){ string } 634 value: (string){ string } 635 } 636 out: (#struct){ 637 val0: (string){ "foo" } 638 msgObj: (string){ "foo" } 639 value: (string){ "foo" } 640 } 641 } 642 } 643 out: (struct){ 644 #base: (#struct){ 645 val0: (string){ string } 646 msgObj: (string){ string } 647 value: (string){ string } 648 } 649 out: (#struct){ 650 val0: (string){ "foo" } 651 msgObj: (string){ "foo" } 652 value: (string){ "foo" } 653 } 654 } 655 } 656 full: (struct){ 657 #Output: (#struct){ 658 namespace: (string){ string } 659 output: (_|_){ 660 // [incomplete] issue3801.nonRooted.full.#Output.output: invalid non-ground value string (must be concrete string): 661 // ./nested.cue:85:15 662 // ./nested.cue:74:15 663 _: (string){ "foo" } 664 } 665 } 666 out: (struct){ 667 ns1: (string){ "foo" } 668 } 669 #SubOutput: (#struct){ 670 namespace?: (string){ string } 671 patch: (_){ _ } 672 output: (_|_){ 673 // [incomplete] issue3801.nonRooted.full.#SubOutput.output: cannot reference optional field: namespace: 674 // ./nested.cue:88:12 675 } 676 } 677 #Base: (#struct){ 678 val0: (string){ string } 679 let msgObj#D = (string){ string } 680 value: (string){ string } 681 } 682 } 683 } 684 } 685 } 686 -- out/compile -- 687 --- nested.cue 688 { 689 issue3801: { 690 let: { 691 reduced: { 692 let F#1 = { 693 base: { 694 in: string 695 let X#2 = { 696 a: "\(〈1;in〉)" 697 }.a 698 out: 〈0;let X#2〉 699 } 700 XXX: (〈0;base〉 & { 701 in: "foo" 702 }) 703 } 704 z: 〈0;let F#1〉.XXX.out 705 } 706 } 707 } 708 issue3801: { 709 nonRooted: { 710 reduced: { 711 #Output: { 712 output: { 713 #base: { 714 val0: string 715 msgObj: { 716 a: 〈1;val0〉 717 }.a 718 value: 〈0;msgObj〉 719 } 720 out: (〈0;#base〉 & { 721 val0: "foo" 722 }) 723 } 724 } 725 out: (〈0;#Output〉 & {}).output 726 } 727 } 728 } 729 issue3801: { 730 let: { 731 full: { 732 #Resource: { 733 someMsg: string 734 obs: ({}|*{ 735 missing: true 736 }) 737 let pickMsg#4 = [ 738 if 〈1;obs〉.missing { 739 msg: "\(〈2;someMsg〉)" 740 }, 741 { 742 msg: "bar" 743 }, 744 ][0] 745 patches: [ 746 { 747 op: "add" 748 path: "/metadata" 749 value: 〈2;let pickMsg#4〉.msg 750 }, 751 ] 752 } 753 #Patches: { 754 [string]: _ 755 } 756 #JSONPatch: { 757 namespace?: string 758 patch: [ 759 ...〈2;#JSONOp〉, 760 ] 761 output: (〈1;#Patches〉 & { 762 〈1;namespace〉: 〈1;patch〉 763 }) 764 } 765 #JSONOp: ({ 766 op: "add" 767 path: string 768 value: _ 769 }|{ 770 op: "remove" 771 path: string 772 }) 773 #Main: { 774 namespace: string 775 output: 〈0;let jsonPatch#5〉.output 776 let jsonPatch#5 = (〈1;#JSONPatch〉 & { 777 let base#8 = (〈2;#Resource〉 & {}) 778 let withMsg#9 = (〈0;let base#8〉 & { 779 someMsg: "foo" 780 }) 781 namespace: 〈1;namespace〉 782 patch: 〈0;let withMsg#9〉.patches 783 }) 784 } 785 out: (〈0;#Main〉 & { 786 namespace: "ns1" 787 }).output 788 } 789 } 790 } 791 issue3801: { 792 nonRooted: { 793 full: { 794 #Output: { 795 namespace: string 796 output: (〈1;#SubOutput〉 & { 797 namespace: 〈1;namespace〉 798 let base2#A = { 799 let base#B = (〈3;#Base〉 & {}) 800 output: (〈0;let base#B〉 & { 801 val0: "foo" 802 }) 803 } 804 patch: 〈0;let base2#A〉.output.value 805 }).output 806 } 807 out: (〈0;#Output〉 & { 808 namespace: "ns1" 809 }).output 810 #SubOutput: { 811 namespace?: string 812 patch: _ 813 output: { 814 〈1;namespace〉: 〈1;patch〉 815 } 816 } 817 #Base: { 818 val0: string 819 let msgObj#D = [ 820 〈1;val0〉, 821 ][0] 822 value: 〈0;let msgObj#D〉 823 } 824 } 825 } 826 } 827 }