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