cuelang.org/go@v0.10.1/cue/testdata/definitions/fields.txtar (about) 1 // Tests fields.go 2 3 -- in.cue -- 4 // TODO: reorganize ordered on what is tested by name. E.g. 5 // insertion: longPath: ok: p1: { 6 // a: .... @fail() 7 // } 8 9 ok: t1: { 10 c: #R 11 c: [{b: int}] 12 #R: [...] 13 } 14 15 ok: t2: { 16 #A: _ 17 l: #A 18 l: f: "hi" 19 } 20 21 ok: t3: { 22 #A: f: {...} 23 #A1: { #A } 24 s: [string]: #A1 25 s: foo: f: d: foo: 1 26 } 27 28 ok: t4: { 29 #T: { a: b: 1 } 30 W: { 31 {#T} 32 b: c: 2 33 } 34 } 35 36 ok: t5: { 37 // TODO: this should pass 38 #A: { 39 Common 40 _ 41 } 42 Common: { } 43 x: #A 44 x: c: int 45 } 46 47 ok: t6: { 48 #A: { 49 Common 50 ... 51 } 52 Common: { } 53 x: #A 54 x: c: int 55 } 56 57 ok: t7: { 58 a: {#A, #B} 59 #A: b: f: 1 60 #B: b: g: 1 61 } 62 63 ok: t8: { 64 // TODO: this should pass 65 foo: #X 66 #X: { 67 a: b: c: C: 1 68 for k, _ in a { 69 // dynamic field causes insertion one level higher. This causes 70 // b to be inserted in a, after it has been referenced. 71 a: (k): c: D: 2 72 } 73 } 74 } 75 76 ok: t9: { 77 c: #R 78 c: [{b: int}] 79 #R: [...] 80 } 81 82 ok: t10: { 83 #A: _ // top should allow everything 84 l: #A 85 l: f: "hi" 86 } 87 88 ok: t11: { 89 // indirections 90 #A: f: {...} 91 #A1: { #A } 92 s: [string]: #A1 93 s: foo: f: d: foo: "bar" // should pass 94 } 95 96 ok: t12: { 97 // nested embedding 98 #T: { a: b: 1 } 99 W: { 100 {#T} 101 b: c: 2 102 } 103 } 104 105 ok: t13: { 106 // TODO: this should pass 107 108 // top opens up 109 #A: { 110 Common 111 _ 112 } 113 Common: { } 114 x: #A 115 x: c: int 116 } 117 118 ok: t14: { 119 // ellipsis opens up 120 #A: { 121 Common 122 ... 123 } 124 Common: { } 125 x: #A 126 x: c: int 127 } 128 129 130 err: t1: { 131 #D: _ & {a: 2} 132 a: #D 133 a: disallowed: 1 134 } 135 136 err: t2: { 137 #S: { { c: d: 1 } } 138 V: #S 139 V: { c: e: 1 } 140 } 141 142 err: t3: p1: { 143 #D: {} 144 a: #D 145 a: c: "C" 146 } 147 148 err: t3: p2: { 149 #D: b: {} 150 a: #D 151 a: b: c: "C" 152 } 153 154 err: t4: { 155 a: #A 156 #A: b: f: 1 157 a: b: h: 1 158 } 159 160 err: t5: { 161 // TODO: this should fail 162 a: {#A, #B} 163 #A: b: f: 1 164 #B: b: g: 1 165 b: a 166 b: b: h: 1 // only an error here 167 } 168 169 err: t6: { 170 // TODO: this should fail 171 a: {#A, #B} 172 #A: b: c: d: e: f: 1 173 #B: b: c: d: e: g: 1 174 b: a 175 b: b: c: d: e: h: 1 // only an error here 176 } 177 178 err: t7: { 179 #D: _ & {a: 2} 180 a: #D 181 a: b: 1 // FAIL 182 } 183 184 err: t8: { 185 // nested embedding 186 #S: { { c: d: 1 } } 187 V: #S 188 V: { c: e: 1 } // Should fail 189 } 190 -- issue1830.cue -- 191 issue1830: { 192 #x: { 193 y: { 194 z?: { 195 name: string 196 } 197 } 198 } 199 200 egs: { 201 x1: (#x & {y: z: _}).y.z & { 202 name: "blah" 203 age1: 5 204 } 205 x2: (#x.y & {z: _}).z & { 206 name: "blah" 207 age2: 5 208 } 209 } 210 } 211 -- out/eval/stats -- 212 Leaks: 3 213 Freed: 210 214 Reused: 203 215 Allocs: 10 216 Retain: 19 217 218 Unifications: 213 219 Conjuncts: 388 220 Disjuncts: 229 221 -- out/evalalpha -- 222 Errors: 223 err.t2.V.c.e: field not allowed: 224 ./in.cue:136:10 225 err.t3.p2.a.b.c: field not allowed: 226 ./in.cue:148:8 227 err.t4.a.b.h: field not allowed: 228 ./in.cue:154:8 229 err.t5.b.b.h: field not allowed: 230 ./in.cue:163:8 231 err.t6.b.b.c.d.e.h: field not allowed: 232 ./in.cue:172:17 233 err.t8.V.c.e: field not allowed: 234 ./in.cue:185:10 235 ok.t5.x.c: field not allowed: 236 ./in.cue:36:3 237 ./in.cue:41:5 238 ok.t13.x.c: field not allowed: 239 ./in.cue:107:3 240 ./in.cue:112:5 241 err.t1.a.disallowed: field not allowed: 242 ./in.cue:129:5 243 ./in.cue:130:5 244 err.t3.p1.a.c: field not allowed: 245 ./in.cue:141:5 246 ./in.cue:142:5 247 err.t7.a.b: field not allowed: 248 ./in.cue:177:5 249 ./in.cue:178:5 250 issue1830.egs.x1.age1: field not allowed: 251 ./issue1830.cue:11:7 252 ./issue1830.cue:13:4 253 issue1830.egs.x2.age2: field not allowed: 254 ./issue1830.cue:15:7 255 ./issue1830.cue:17:4 256 257 Result: 258 (_|_){ 259 // [eval] 260 ok: (_|_){ 261 // [eval] 262 t1: (struct){ 263 c: (#list){ 264 0: (#struct){ 265 b: (int){ int } 266 } 267 } 268 #R: (list){ 269 } 270 } 271 t2: (struct){ 272 #A: (_){ _ } 273 l: (#struct){ 274 f: (string){ "hi" } 275 } 276 } 277 t3: (struct){ 278 #A: (#struct){ 279 f: (#struct){ 280 } 281 } 282 #A1: (#struct){ 283 f: (#struct){ 284 } 285 } 286 s: (struct){ 287 foo: (#struct){ 288 f: (#struct){ 289 d: (struct){ 290 foo: (int){ 1 } 291 } 292 } 293 } 294 } 295 } 296 t4: (struct){ 297 #T: (#struct){ 298 a: (#struct){ 299 b: (int){ 1 } 300 } 301 } 302 W: (#struct){ 303 b: (struct){ 304 c: (int){ 2 } 305 } 306 a: (#struct){ 307 b: (int){ 1 } 308 } 309 } 310 } 311 t5: (_|_){ 312 // [eval] 313 #A: (#struct){ 314 } 315 Common: (struct){ 316 } 317 x: (_|_){ 318 // [eval] 319 c: (_|_){ 320 // [eval] ok.t5.x.c: field not allowed: 321 // ./in.cue:36:3 322 // ./in.cue:41:5 323 } 324 } 325 } 326 t6: (struct){ 327 #A: (#struct){ 328 } 329 Common: (struct){ 330 } 331 x: (#struct){ 332 c: (int){ int } 333 } 334 } 335 t7: (struct){ 336 a: (#struct){ 337 b: (#struct){ 338 f: (int){ 1 } 339 g: (int){ 1 } 340 } 341 } 342 #A: (#struct){ 343 b: (#struct){ 344 f: (int){ 1 } 345 } 346 } 347 #B: (#struct){ 348 b: (#struct){ 349 g: (int){ 1 } 350 } 351 } 352 } 353 t8: (struct){ 354 foo: (#struct){ 355 a: (#struct){ 356 b: (#struct){ 357 c: (#struct){ 358 C: (int){ 1 } 359 D: (int){ 2 } 360 } 361 } 362 } 363 } 364 #X: (#struct){ 365 a: (#struct){ 366 b: (#struct){ 367 c: (#struct){ 368 C: (int){ 1 } 369 D: (int){ 2 } 370 } 371 } 372 } 373 } 374 } 375 t9: (struct){ 376 c: (#list){ 377 0: (#struct){ 378 b: (int){ int } 379 } 380 } 381 #R: (list){ 382 } 383 } 384 t10: (struct){ 385 #A: (_){ _ } 386 l: (#struct){ 387 f: (string){ "hi" } 388 } 389 } 390 t11: (struct){ 391 #A: (#struct){ 392 f: (#struct){ 393 } 394 } 395 #A1: (#struct){ 396 f: (#struct){ 397 } 398 } 399 s: (struct){ 400 foo: (#struct){ 401 f: (#struct){ 402 d: (struct){ 403 foo: (string){ "bar" } 404 } 405 } 406 } 407 } 408 } 409 t12: (struct){ 410 #T: (#struct){ 411 a: (#struct){ 412 b: (int){ 1 } 413 } 414 } 415 W: (#struct){ 416 b: (struct){ 417 c: (int){ 2 } 418 } 419 a: (#struct){ 420 b: (int){ 1 } 421 } 422 } 423 } 424 t13: (_|_){ 425 // [eval] 426 #A: (#struct){ 427 } 428 Common: (struct){ 429 } 430 x: (_|_){ 431 // [eval] 432 c: (_|_){ 433 // [eval] ok.t13.x.c: field not allowed: 434 // ./in.cue:107:3 435 // ./in.cue:112:5 436 } 437 } 438 } 439 t14: (struct){ 440 #A: (#struct){ 441 } 442 Common: (struct){ 443 } 444 x: (#struct){ 445 c: (int){ int } 446 } 447 } 448 } 449 err: (_|_){ 450 // [eval] 451 t1: (_|_){ 452 // [eval] 453 #D: (#struct){ 454 a: (int){ 2 } 455 } 456 a: (_|_){ 457 // [eval] 458 disallowed: (_|_){ 459 // [eval] err.t1.a.disallowed: field not allowed: 460 // ./in.cue:129:5 461 // ./in.cue:130:5 462 } 463 a: (int){ 2 } 464 } 465 } 466 t2: (_|_){ 467 // [eval] 468 #S: (#struct){ 469 c: (#struct){ 470 d: (int){ 1 } 471 } 472 } 473 V: (_|_){ 474 // [eval] 475 c: (_|_){ 476 // [eval] 477 e: (_|_){ 478 // [eval] err.t2.V.c.e: field not allowed: 479 // ./in.cue:136:10 480 } 481 d: (int){ 1 } 482 } 483 } 484 } 485 t3: (_|_){ 486 // [eval] 487 p1: (_|_){ 488 // [eval] 489 #D: (#struct){ 490 } 491 a: (_|_){ 492 // [eval] 493 c: (_|_){ 494 // [eval] err.t3.p1.a.c: field not allowed: 495 // ./in.cue:141:5 496 // ./in.cue:142:5 497 } 498 } 499 } 500 p2: (_|_){ 501 // [eval] 502 #D: (#struct){ 503 b: (#struct){ 504 } 505 } 506 a: (_|_){ 507 // [eval] 508 b: (_|_){ 509 // [eval] 510 c: (_|_){ 511 // [eval] err.t3.p2.a.b.c: field not allowed: 512 // ./in.cue:148:8 513 } 514 } 515 } 516 } 517 } 518 t4: (_|_){ 519 // [eval] 520 a: (_|_){ 521 // [eval] 522 b: (_|_){ 523 // [eval] 524 h: (_|_){ 525 // [eval] err.t4.a.b.h: field not allowed: 526 // ./in.cue:154:8 527 } 528 f: (int){ 1 } 529 } 530 } 531 #A: (#struct){ 532 b: (#struct){ 533 f: (int){ 1 } 534 } 535 } 536 } 537 t5: (_|_){ 538 // [eval] 539 a: (#struct){ 540 b: (#struct){ 541 f: (int){ 1 } 542 g: (int){ 1 } 543 } 544 } 545 #A: (#struct){ 546 b: (#struct){ 547 f: (int){ 1 } 548 } 549 } 550 #B: (#struct){ 551 b: (#struct){ 552 g: (int){ 1 } 553 } 554 } 555 b: (_|_){ 556 // [eval] 557 b: (_|_){ 558 // [eval] 559 h: (_|_){ 560 // [eval] err.t5.b.b.h: field not allowed: 561 // ./in.cue:163:8 562 } 563 f: (int){ 1 } 564 g: (int){ 1 } 565 } 566 } 567 } 568 t6: (_|_){ 569 // [eval] 570 a: (#struct){ 571 b: (#struct){ 572 c: (#struct){ 573 d: (#struct){ 574 e: (#struct){ 575 f: (int){ 1 } 576 g: (int){ 1 } 577 } 578 } 579 } 580 } 581 } 582 #A: (#struct){ 583 b: (#struct){ 584 c: (#struct){ 585 d: (#struct){ 586 e: (#struct){ 587 f: (int){ 1 } 588 } 589 } 590 } 591 } 592 } 593 #B: (#struct){ 594 b: (#struct){ 595 c: (#struct){ 596 d: (#struct){ 597 e: (#struct){ 598 g: (int){ 1 } 599 } 600 } 601 } 602 } 603 } 604 b: (_|_){ 605 // [eval] 606 b: (_|_){ 607 // [eval] 608 c: (_|_){ 609 // [eval] 610 d: (_|_){ 611 // [eval] 612 e: (_|_){ 613 // [eval] 614 h: (_|_){ 615 // [eval] err.t6.b.b.c.d.e.h: field not allowed: 616 // ./in.cue:172:17 617 } 618 f: (int){ 1 } 619 g: (int){ 1 } 620 } 621 } 622 } 623 } 624 } 625 } 626 t7: (_|_){ 627 // [eval] 628 #D: (#struct){ 629 a: (int){ 2 } 630 } 631 a: (_|_){ 632 // [eval] 633 b: (_|_){ 634 // [eval] err.t7.a.b: field not allowed: 635 // ./in.cue:177:5 636 // ./in.cue:178:5 637 } 638 a: (int){ 2 } 639 } 640 } 641 t8: (_|_){ 642 // [eval] 643 #S: (#struct){ 644 c: (#struct){ 645 d: (int){ 1 } 646 } 647 } 648 V: (_|_){ 649 // [eval] 650 c: (_|_){ 651 // [eval] 652 e: (_|_){ 653 // [eval] err.t8.V.c.e: field not allowed: 654 // ./in.cue:185:10 655 } 656 d: (int){ 1 } 657 } 658 } 659 } 660 } 661 issue1830: (_|_){ 662 // [eval] 663 #x: (#struct){ 664 y: (#struct){ 665 z?: (#struct){ 666 name: (string){ string } 667 } 668 } 669 } 670 egs: (_|_){ 671 // [eval] 672 x1: (_|_){ 673 // [eval] 674 name: (string){ "blah" } 675 age1: (_|_){ 676 // [eval] issue1830.egs.x1.age1: field not allowed: 677 // ./issue1830.cue:11:7 678 // ./issue1830.cue:13:4 679 } 680 } 681 x2: (_|_){ 682 // [eval] 683 name: (string){ "blah" } 684 age2: (_|_){ 685 // [eval] issue1830.egs.x2.age2: field not allowed: 686 // ./issue1830.cue:15:7 687 // ./issue1830.cue:17:4 688 } 689 } 690 } 691 } 692 } 693 -- diff/-out/evalalpha<==>+out/eval -- 694 diff old new 695 --- old 696 +++ new 697 @@ -1,60 +1,37 @@ 698 Errors: 699 -err.t1.a.disallowed: field not allowed: 700 - ./in.cue:128:10 701 - ./in.cue:129:5 702 - ./in.cue:130:5 703 err.t2.V.c.e: field not allowed: 704 - ./in.cue:134:8 705 - ./in.cue:134:13 706 - ./in.cue:135:5 707 ./in.cue:136:10 708 -err.t3.p1.a.c: field not allowed: 709 - ./in.cue:140:6 710 - ./in.cue:141:5 711 - ./in.cue:142:5 712 err.t3.p2.a.b.c: field not allowed: 713 - ./in.cue:146:9 714 - ./in.cue:147:5 715 ./in.cue:148:8 716 err.t4.a.b.h: field not allowed: 717 - ./in.cue:152:5 718 - ./in.cue:153:9 719 ./in.cue:154:8 720 err.t5.b.b.h: field not allowed: 721 - ./in.cue:159:6 722 - ./in.cue:159:10 723 - ./in.cue:160:9 724 - ./in.cue:161:9 725 - ./in.cue:162:5 726 ./in.cue:163:8 727 err.t6.b.b.c.d.e.h: field not allowed: 728 - ./in.cue:168:6 729 - ./in.cue:168:10 730 - ./in.cue:169:18 731 - ./in.cue:170:18 732 - ./in.cue:171:5 733 ./in.cue:172:17 734 -err.t7.a.b: field not allowed: 735 - ./in.cue:176:10 736 - ./in.cue:177:5 737 - ./in.cue:178:5 738 err.t8.V.c.e: field not allowed: 739 - ./in.cue:183:8 740 - ./in.cue:183:13 741 - ./in.cue:184:5 742 ./in.cue:185:10 743 -ok.t13.x.c: field not allowed: 744 - ./in.cue:106:6 745 - ./in.cue:107:3 746 - ./in.cue:110:10 747 - ./in.cue:111:5 748 - ./in.cue:112:5 749 ok.t5.x.c: field not allowed: 750 - ./in.cue:35:6 751 ./in.cue:36:3 752 - ./in.cue:39:10 753 - ./in.cue:40:5 754 ./in.cue:41:5 755 +ok.t13.x.c: field not allowed: 756 + ./in.cue:107:3 757 + ./in.cue:112:5 758 +err.t1.a.disallowed: field not allowed: 759 + ./in.cue:129:5 760 + ./in.cue:130:5 761 +err.t3.p1.a.c: field not allowed: 762 + ./in.cue:141:5 763 + ./in.cue:142:5 764 +err.t7.a.b: field not allowed: 765 + ./in.cue:177:5 766 + ./in.cue:178:5 767 +issue1830.egs.x1.age1: field not allowed: 768 + ./issue1830.cue:11:7 769 + ./issue1830.cue:13:4 770 +issue1830.egs.x2.age2: field not allowed: 771 + ./issue1830.cue:15:7 772 + ./issue1830.cue:17:4 773 774 Result: 775 (_|_){ 776 @@ -63,7 +40,7 @@ 777 // [eval] 778 t1: (struct){ 779 c: (#list){ 780 - 0: (struct){ 781 + 0: (#struct){ 782 b: (int){ int } 783 } 784 } 785 @@ -72,7 +49,7 @@ 786 } 787 t2: (struct){ 788 #A: (_){ _ } 789 - l: (struct){ 790 + l: (#struct){ 791 f: (string){ "hi" } 792 } 793 } 794 @@ -102,11 +79,11 @@ 795 } 796 } 797 W: (#struct){ 798 - a: (#struct){ 799 - b: (int){ 1 } 800 - } 801 - b: (struct){ 802 - c: (int){ 2 } 803 + b: (struct){ 804 + c: (int){ 2 } 805 + } 806 + a: (#struct){ 807 + b: (int){ 1 } 808 } 809 } 810 } 811 @@ -120,10 +97,7 @@ 812 // [eval] 813 c: (_|_){ 814 // [eval] ok.t5.x.c: field not allowed: 815 - // ./in.cue:35:6 816 // ./in.cue:36:3 817 - // ./in.cue:39:10 818 - // ./in.cue:40:5 819 // ./in.cue:41:5 820 } 821 } 822 @@ -179,7 +153,7 @@ 823 } 824 t9: (struct){ 825 c: (#list){ 826 - 0: (struct){ 827 + 0: (#struct){ 828 b: (int){ int } 829 } 830 } 831 @@ -188,7 +162,7 @@ 832 } 833 t10: (struct){ 834 #A: (_){ _ } 835 - l: (struct){ 836 + l: (#struct){ 837 f: (string){ "hi" } 838 } 839 } 840 @@ -218,11 +192,11 @@ 841 } 842 } 843 W: (#struct){ 844 - a: (#struct){ 845 - b: (int){ 1 } 846 - } 847 - b: (struct){ 848 - c: (int){ 2 } 849 + b: (struct){ 850 + c: (int){ 2 } 851 + } 852 + a: (#struct){ 853 + b: (int){ 1 } 854 } 855 } 856 } 857 @@ -236,10 +210,7 @@ 858 // [eval] 859 c: (_|_){ 860 // [eval] ok.t13.x.c: field not allowed: 861 - // ./in.cue:106:6 862 // ./in.cue:107:3 863 - // ./in.cue:110:10 864 - // ./in.cue:111:5 865 // ./in.cue:112:5 866 } 867 } 868 @@ -263,13 +234,12 @@ 869 } 870 a: (_|_){ 871 // [eval] 872 - a: (int){ 2 } 873 disallowed: (_|_){ 874 // [eval] err.t1.a.disallowed: field not allowed: 875 - // ./in.cue:128:10 876 // ./in.cue:129:5 877 // ./in.cue:130:5 878 } 879 + a: (int){ 2 } 880 } 881 } 882 t2: (_|_){ 883 @@ -283,14 +253,11 @@ 884 // [eval] 885 c: (_|_){ 886 // [eval] 887 - d: (int){ 1 } 888 e: (_|_){ 889 // [eval] err.t2.V.c.e: field not allowed: 890 - // ./in.cue:134:8 891 - // ./in.cue:134:13 892 - // ./in.cue:135:5 893 // ./in.cue:136:10 894 } 895 + d: (int){ 1 } 896 } 897 } 898 } 899 @@ -304,7 +271,6 @@ 900 // [eval] 901 c: (_|_){ 902 // [eval] err.t3.p1.a.c: field not allowed: 903 - // ./in.cue:140:6 904 // ./in.cue:141:5 905 // ./in.cue:142:5 906 } 907 @@ -322,8 +288,6 @@ 908 // [eval] 909 c: (_|_){ 910 // [eval] err.t3.p2.a.b.c: field not allowed: 911 - // ./in.cue:146:9 912 - // ./in.cue:147:5 913 // ./in.cue:148:8 914 } 915 } 916 @@ -336,54 +300,47 @@ 917 // [eval] 918 b: (_|_){ 919 // [eval] 920 - f: (int){ 1 } 921 h: (_|_){ 922 // [eval] err.t4.a.b.h: field not allowed: 923 - // ./in.cue:152:5 924 - // ./in.cue:153:9 925 // ./in.cue:154:8 926 } 927 - } 928 - } 929 - #A: (#struct){ 930 - b: (#struct){ 931 - f: (int){ 1 } 932 - } 933 - } 934 - } 935 - t5: (_|_){ 936 - // [eval] 937 - a: (#struct){ 938 - b: (#struct){ 939 - f: (int){ 1 } 940 - g: (int){ 1 } 941 - } 942 - } 943 - #A: (#struct){ 944 - b: (#struct){ 945 - f: (int){ 1 } 946 - } 947 - } 948 - #B: (#struct){ 949 - b: (#struct){ 950 - g: (int){ 1 } 951 - } 952 - } 953 - b: (_|_){ 954 - // [eval] 955 - b: (_|_){ 956 - // [eval] 957 - f: (int){ 1 } 958 - g: (int){ 1 } 959 + f: (int){ 1 } 960 + } 961 + } 962 + #A: (#struct){ 963 + b: (#struct){ 964 + f: (int){ 1 } 965 + } 966 + } 967 + } 968 + t5: (_|_){ 969 + // [eval] 970 + a: (#struct){ 971 + b: (#struct){ 972 + f: (int){ 1 } 973 + g: (int){ 1 } 974 + } 975 + } 976 + #A: (#struct){ 977 + b: (#struct){ 978 + f: (int){ 1 } 979 + } 980 + } 981 + #B: (#struct){ 982 + b: (#struct){ 983 + g: (int){ 1 } 984 + } 985 + } 986 + b: (_|_){ 987 + // [eval] 988 + b: (_|_){ 989 + // [eval] 990 h: (_|_){ 991 // [eval] err.t5.b.b.h: field not allowed: 992 - // ./in.cue:159:6 993 - // ./in.cue:159:10 994 - // ./in.cue:160:9 995 - // ./in.cue:161:9 996 - // ./in.cue:162:5 997 // ./in.cue:163:8 998 } 999 + f: (int){ 1 } 1000 + g: (int){ 1 } 1001 } 1002 } 1003 } 1004 @@ -433,17 +390,12 @@ 1005 // [eval] 1006 e: (_|_){ 1007 // [eval] 1008 - f: (int){ 1 } 1009 - g: (int){ 1 } 1010 h: (_|_){ 1011 // [eval] err.t6.b.b.c.d.e.h: field not allowed: 1012 - // ./in.cue:168:6 1013 - // ./in.cue:168:10 1014 - // ./in.cue:169:18 1015 - // ./in.cue:170:18 1016 - // ./in.cue:171:5 1017 // ./in.cue:172:17 1018 } 1019 + f: (int){ 1 } 1020 + g: (int){ 1 } 1021 } 1022 } 1023 } 1024 @@ -457,13 +409,12 @@ 1025 } 1026 a: (_|_){ 1027 // [eval] 1028 - a: (int){ 2 } 1029 b: (_|_){ 1030 // [eval] err.t7.a.b: field not allowed: 1031 - // ./in.cue:176:10 1032 // ./in.cue:177:5 1033 // ./in.cue:178:5 1034 } 1035 + a: (int){ 2 } 1036 } 1037 } 1038 t8: (_|_){ 1039 @@ -477,19 +428,17 @@ 1040 // [eval] 1041 c: (_|_){ 1042 // [eval] 1043 - d: (int){ 1 } 1044 e: (_|_){ 1045 // [eval] err.t8.V.c.e: field not allowed: 1046 - // ./in.cue:183:8 1047 - // ./in.cue:183:13 1048 - // ./in.cue:184:5 1049 // ./in.cue:185:10 1050 } 1051 - } 1052 - } 1053 - } 1054 - } 1055 - issue1830: (struct){ 1056 + d: (int){ 1 } 1057 + } 1058 + } 1059 + } 1060 + } 1061 + issue1830: (_|_){ 1062 + // [eval] 1063 #x: (#struct){ 1064 y: (#struct){ 1065 z?: (#struct){ 1066 @@ -497,14 +446,25 @@ 1067 } 1068 } 1069 } 1070 - egs: (struct){ 1071 - x1: (struct){ 1072 - name: (string){ "blah" } 1073 - age1: (int){ 5 } 1074 - } 1075 - x2: (struct){ 1076 - name: (string){ "blah" } 1077 - age2: (int){ 5 } 1078 + egs: (_|_){ 1079 + // [eval] 1080 + x1: (_|_){ 1081 + // [eval] 1082 + name: (string){ "blah" } 1083 + age1: (_|_){ 1084 + // [eval] issue1830.egs.x1.age1: field not allowed: 1085 + // ./issue1830.cue:11:7 1086 + // ./issue1830.cue:13:4 1087 + } 1088 + } 1089 + x2: (_|_){ 1090 + // [eval] 1091 + name: (string){ "blah" } 1092 + age2: (_|_){ 1093 + // [eval] issue1830.egs.x2.age2: field not allowed: 1094 + // ./issue1830.cue:15:7 1095 + // ./issue1830.cue:17:4 1096 + } 1097 } 1098 } 1099 } 1100 -- diff/todo/p2 -- 1101 ok.t1.c.0: closedness probably incorrect: #R defines elements as type "top", 1102 which are not closed by definition. Probably does not matter for evaluation, 1103 as it will be determined to be "closed", but allowing all attributes. 1104 ok.t(9|10).c.0: same issue as ok.t1.c.0. 1105 ok.t2.l: same issue: top is marked as "closed", even though it will allow all 1106 values. Probably just a matter of difference in debugging output and not 1107 evaluation semantics. 1108 all: error positions and reordering. 1109 -- diff/explanation -- 1110 ok.t5 and ok.t13 retain semantics of v0.6 for now. 1111 issue1830: the new evaluator correctly rejects inserting new fields in a closed struct 1112 -- out/eval -- 1113 Errors: 1114 err.t1.a.disallowed: field not allowed: 1115 ./in.cue:128:10 1116 ./in.cue:129:5 1117 ./in.cue:130:5 1118 err.t2.V.c.e: field not allowed: 1119 ./in.cue:134:8 1120 ./in.cue:134:13 1121 ./in.cue:135:5 1122 ./in.cue:136:10 1123 err.t3.p1.a.c: field not allowed: 1124 ./in.cue:140:6 1125 ./in.cue:141:5 1126 ./in.cue:142:5 1127 err.t3.p2.a.b.c: field not allowed: 1128 ./in.cue:146:9 1129 ./in.cue:147:5 1130 ./in.cue:148:8 1131 err.t4.a.b.h: field not allowed: 1132 ./in.cue:152:5 1133 ./in.cue:153:9 1134 ./in.cue:154:8 1135 err.t5.b.b.h: field not allowed: 1136 ./in.cue:159:6 1137 ./in.cue:159:10 1138 ./in.cue:160:9 1139 ./in.cue:161:9 1140 ./in.cue:162:5 1141 ./in.cue:163:8 1142 err.t6.b.b.c.d.e.h: field not allowed: 1143 ./in.cue:168:6 1144 ./in.cue:168:10 1145 ./in.cue:169:18 1146 ./in.cue:170:18 1147 ./in.cue:171:5 1148 ./in.cue:172:17 1149 err.t7.a.b: field not allowed: 1150 ./in.cue:176:10 1151 ./in.cue:177:5 1152 ./in.cue:178:5 1153 err.t8.V.c.e: field not allowed: 1154 ./in.cue:183:8 1155 ./in.cue:183:13 1156 ./in.cue:184:5 1157 ./in.cue:185:10 1158 ok.t13.x.c: field not allowed: 1159 ./in.cue:106:6 1160 ./in.cue:107:3 1161 ./in.cue:110:10 1162 ./in.cue:111:5 1163 ./in.cue:112:5 1164 ok.t5.x.c: field not allowed: 1165 ./in.cue:35:6 1166 ./in.cue:36:3 1167 ./in.cue:39:10 1168 ./in.cue:40:5 1169 ./in.cue:41:5 1170 1171 Result: 1172 (_|_){ 1173 // [eval] 1174 ok: (_|_){ 1175 // [eval] 1176 t1: (struct){ 1177 c: (#list){ 1178 0: (struct){ 1179 b: (int){ int } 1180 } 1181 } 1182 #R: (list){ 1183 } 1184 } 1185 t2: (struct){ 1186 #A: (_){ _ } 1187 l: (struct){ 1188 f: (string){ "hi" } 1189 } 1190 } 1191 t3: (struct){ 1192 #A: (#struct){ 1193 f: (#struct){ 1194 } 1195 } 1196 #A1: (#struct){ 1197 f: (#struct){ 1198 } 1199 } 1200 s: (struct){ 1201 foo: (#struct){ 1202 f: (#struct){ 1203 d: (struct){ 1204 foo: (int){ 1 } 1205 } 1206 } 1207 } 1208 } 1209 } 1210 t4: (struct){ 1211 #T: (#struct){ 1212 a: (#struct){ 1213 b: (int){ 1 } 1214 } 1215 } 1216 W: (#struct){ 1217 a: (#struct){ 1218 b: (int){ 1 } 1219 } 1220 b: (struct){ 1221 c: (int){ 2 } 1222 } 1223 } 1224 } 1225 t5: (_|_){ 1226 // [eval] 1227 #A: (#struct){ 1228 } 1229 Common: (struct){ 1230 } 1231 x: (_|_){ 1232 // [eval] 1233 c: (_|_){ 1234 // [eval] ok.t5.x.c: field not allowed: 1235 // ./in.cue:35:6 1236 // ./in.cue:36:3 1237 // ./in.cue:39:10 1238 // ./in.cue:40:5 1239 // ./in.cue:41:5 1240 } 1241 } 1242 } 1243 t6: (struct){ 1244 #A: (#struct){ 1245 } 1246 Common: (struct){ 1247 } 1248 x: (#struct){ 1249 c: (int){ int } 1250 } 1251 } 1252 t7: (struct){ 1253 a: (#struct){ 1254 b: (#struct){ 1255 f: (int){ 1 } 1256 g: (int){ 1 } 1257 } 1258 } 1259 #A: (#struct){ 1260 b: (#struct){ 1261 f: (int){ 1 } 1262 } 1263 } 1264 #B: (#struct){ 1265 b: (#struct){ 1266 g: (int){ 1 } 1267 } 1268 } 1269 } 1270 t8: (struct){ 1271 foo: (#struct){ 1272 a: (#struct){ 1273 b: (#struct){ 1274 c: (#struct){ 1275 C: (int){ 1 } 1276 D: (int){ 2 } 1277 } 1278 } 1279 } 1280 } 1281 #X: (#struct){ 1282 a: (#struct){ 1283 b: (#struct){ 1284 c: (#struct){ 1285 C: (int){ 1 } 1286 D: (int){ 2 } 1287 } 1288 } 1289 } 1290 } 1291 } 1292 t9: (struct){ 1293 c: (#list){ 1294 0: (struct){ 1295 b: (int){ int } 1296 } 1297 } 1298 #R: (list){ 1299 } 1300 } 1301 t10: (struct){ 1302 #A: (_){ _ } 1303 l: (struct){ 1304 f: (string){ "hi" } 1305 } 1306 } 1307 t11: (struct){ 1308 #A: (#struct){ 1309 f: (#struct){ 1310 } 1311 } 1312 #A1: (#struct){ 1313 f: (#struct){ 1314 } 1315 } 1316 s: (struct){ 1317 foo: (#struct){ 1318 f: (#struct){ 1319 d: (struct){ 1320 foo: (string){ "bar" } 1321 } 1322 } 1323 } 1324 } 1325 } 1326 t12: (struct){ 1327 #T: (#struct){ 1328 a: (#struct){ 1329 b: (int){ 1 } 1330 } 1331 } 1332 W: (#struct){ 1333 a: (#struct){ 1334 b: (int){ 1 } 1335 } 1336 b: (struct){ 1337 c: (int){ 2 } 1338 } 1339 } 1340 } 1341 t13: (_|_){ 1342 // [eval] 1343 #A: (#struct){ 1344 } 1345 Common: (struct){ 1346 } 1347 x: (_|_){ 1348 // [eval] 1349 c: (_|_){ 1350 // [eval] ok.t13.x.c: field not allowed: 1351 // ./in.cue:106:6 1352 // ./in.cue:107:3 1353 // ./in.cue:110:10 1354 // ./in.cue:111:5 1355 // ./in.cue:112:5 1356 } 1357 } 1358 } 1359 t14: (struct){ 1360 #A: (#struct){ 1361 } 1362 Common: (struct){ 1363 } 1364 x: (#struct){ 1365 c: (int){ int } 1366 } 1367 } 1368 } 1369 err: (_|_){ 1370 // [eval] 1371 t1: (_|_){ 1372 // [eval] 1373 #D: (#struct){ 1374 a: (int){ 2 } 1375 } 1376 a: (_|_){ 1377 // [eval] 1378 a: (int){ 2 } 1379 disallowed: (_|_){ 1380 // [eval] err.t1.a.disallowed: field not allowed: 1381 // ./in.cue:128:10 1382 // ./in.cue:129:5 1383 // ./in.cue:130:5 1384 } 1385 } 1386 } 1387 t2: (_|_){ 1388 // [eval] 1389 #S: (#struct){ 1390 c: (#struct){ 1391 d: (int){ 1 } 1392 } 1393 } 1394 V: (_|_){ 1395 // [eval] 1396 c: (_|_){ 1397 // [eval] 1398 d: (int){ 1 } 1399 e: (_|_){ 1400 // [eval] err.t2.V.c.e: field not allowed: 1401 // ./in.cue:134:8 1402 // ./in.cue:134:13 1403 // ./in.cue:135:5 1404 // ./in.cue:136:10 1405 } 1406 } 1407 } 1408 } 1409 t3: (_|_){ 1410 // [eval] 1411 p1: (_|_){ 1412 // [eval] 1413 #D: (#struct){ 1414 } 1415 a: (_|_){ 1416 // [eval] 1417 c: (_|_){ 1418 // [eval] err.t3.p1.a.c: field not allowed: 1419 // ./in.cue:140:6 1420 // ./in.cue:141:5 1421 // ./in.cue:142:5 1422 } 1423 } 1424 } 1425 p2: (_|_){ 1426 // [eval] 1427 #D: (#struct){ 1428 b: (#struct){ 1429 } 1430 } 1431 a: (_|_){ 1432 // [eval] 1433 b: (_|_){ 1434 // [eval] 1435 c: (_|_){ 1436 // [eval] err.t3.p2.a.b.c: field not allowed: 1437 // ./in.cue:146:9 1438 // ./in.cue:147:5 1439 // ./in.cue:148:8 1440 } 1441 } 1442 } 1443 } 1444 } 1445 t4: (_|_){ 1446 // [eval] 1447 a: (_|_){ 1448 // [eval] 1449 b: (_|_){ 1450 // [eval] 1451 f: (int){ 1 } 1452 h: (_|_){ 1453 // [eval] err.t4.a.b.h: field not allowed: 1454 // ./in.cue:152:5 1455 // ./in.cue:153:9 1456 // ./in.cue:154:8 1457 } 1458 } 1459 } 1460 #A: (#struct){ 1461 b: (#struct){ 1462 f: (int){ 1 } 1463 } 1464 } 1465 } 1466 t5: (_|_){ 1467 // [eval] 1468 a: (#struct){ 1469 b: (#struct){ 1470 f: (int){ 1 } 1471 g: (int){ 1 } 1472 } 1473 } 1474 #A: (#struct){ 1475 b: (#struct){ 1476 f: (int){ 1 } 1477 } 1478 } 1479 #B: (#struct){ 1480 b: (#struct){ 1481 g: (int){ 1 } 1482 } 1483 } 1484 b: (_|_){ 1485 // [eval] 1486 b: (_|_){ 1487 // [eval] 1488 f: (int){ 1 } 1489 g: (int){ 1 } 1490 h: (_|_){ 1491 // [eval] err.t5.b.b.h: field not allowed: 1492 // ./in.cue:159:6 1493 // ./in.cue:159:10 1494 // ./in.cue:160:9 1495 // ./in.cue:161:9 1496 // ./in.cue:162:5 1497 // ./in.cue:163:8 1498 } 1499 } 1500 } 1501 } 1502 t6: (_|_){ 1503 // [eval] 1504 a: (#struct){ 1505 b: (#struct){ 1506 c: (#struct){ 1507 d: (#struct){ 1508 e: (#struct){ 1509 f: (int){ 1 } 1510 g: (int){ 1 } 1511 } 1512 } 1513 } 1514 } 1515 } 1516 #A: (#struct){ 1517 b: (#struct){ 1518 c: (#struct){ 1519 d: (#struct){ 1520 e: (#struct){ 1521 f: (int){ 1 } 1522 } 1523 } 1524 } 1525 } 1526 } 1527 #B: (#struct){ 1528 b: (#struct){ 1529 c: (#struct){ 1530 d: (#struct){ 1531 e: (#struct){ 1532 g: (int){ 1 } 1533 } 1534 } 1535 } 1536 } 1537 } 1538 b: (_|_){ 1539 // [eval] 1540 b: (_|_){ 1541 // [eval] 1542 c: (_|_){ 1543 // [eval] 1544 d: (_|_){ 1545 // [eval] 1546 e: (_|_){ 1547 // [eval] 1548 f: (int){ 1 } 1549 g: (int){ 1 } 1550 h: (_|_){ 1551 // [eval] err.t6.b.b.c.d.e.h: field not allowed: 1552 // ./in.cue:168:6 1553 // ./in.cue:168:10 1554 // ./in.cue:169:18 1555 // ./in.cue:170:18 1556 // ./in.cue:171:5 1557 // ./in.cue:172:17 1558 } 1559 } 1560 } 1561 } 1562 } 1563 } 1564 } 1565 t7: (_|_){ 1566 // [eval] 1567 #D: (#struct){ 1568 a: (int){ 2 } 1569 } 1570 a: (_|_){ 1571 // [eval] 1572 a: (int){ 2 } 1573 b: (_|_){ 1574 // [eval] err.t7.a.b: field not allowed: 1575 // ./in.cue:176:10 1576 // ./in.cue:177:5 1577 // ./in.cue:178:5 1578 } 1579 } 1580 } 1581 t8: (_|_){ 1582 // [eval] 1583 #S: (#struct){ 1584 c: (#struct){ 1585 d: (int){ 1 } 1586 } 1587 } 1588 V: (_|_){ 1589 // [eval] 1590 c: (_|_){ 1591 // [eval] 1592 d: (int){ 1 } 1593 e: (_|_){ 1594 // [eval] err.t8.V.c.e: field not allowed: 1595 // ./in.cue:183:8 1596 // ./in.cue:183:13 1597 // ./in.cue:184:5 1598 // ./in.cue:185:10 1599 } 1600 } 1601 } 1602 } 1603 } 1604 issue1830: (struct){ 1605 #x: (#struct){ 1606 y: (#struct){ 1607 z?: (#struct){ 1608 name: (string){ string } 1609 } 1610 } 1611 } 1612 egs: (struct){ 1613 x1: (struct){ 1614 name: (string){ "blah" } 1615 age1: (int){ 5 } 1616 } 1617 x2: (struct){ 1618 name: (string){ "blah" } 1619 age2: (int){ 5 } 1620 } 1621 } 1622 } 1623 } 1624 -- out/compile -- 1625 --- in.cue 1626 { 1627 ok: { 1628 t1: { 1629 c: 〈0;#R〉 1630 c: [ 1631 { 1632 b: int 1633 }, 1634 ] 1635 #R: [ 1636 ..., 1637 ] 1638 } 1639 } 1640 ok: { 1641 t2: { 1642 #A: _ 1643 l: 〈0;#A〉 1644 l: { 1645 f: "hi" 1646 } 1647 } 1648 } 1649 ok: { 1650 t3: { 1651 #A: { 1652 f: { 1653 ... 1654 } 1655 } 1656 #A1: { 1657 〈1;#A〉 1658 } 1659 s: { 1660 [string]: 〈1;#A1〉 1661 } 1662 s: { 1663 foo: { 1664 f: { 1665 d: { 1666 foo: 1 1667 } 1668 } 1669 } 1670 } 1671 } 1672 } 1673 ok: { 1674 t4: { 1675 #T: { 1676 a: { 1677 b: 1 1678 } 1679 } 1680 W: { 1681 { 1682 〈2;#T〉 1683 } 1684 b: { 1685 c: 2 1686 } 1687 } 1688 } 1689 } 1690 ok: { 1691 t5: { 1692 #A: { 1693 〈1;Common〉 1694 _ 1695 } 1696 Common: {} 1697 x: 〈0;#A〉 1698 x: { 1699 c: int 1700 } 1701 } 1702 } 1703 ok: { 1704 t6: { 1705 #A: { 1706 〈1;Common〉 1707 ... 1708 } 1709 Common: {} 1710 x: 〈0;#A〉 1711 x: { 1712 c: int 1713 } 1714 } 1715 } 1716 ok: { 1717 t7: { 1718 a: { 1719 〈1;#A〉 1720 〈1;#B〉 1721 } 1722 #A: { 1723 b: { 1724 f: 1 1725 } 1726 } 1727 #B: { 1728 b: { 1729 g: 1 1730 } 1731 } 1732 } 1733 } 1734 ok: { 1735 t8: { 1736 foo: 〈0;#X〉 1737 #X: { 1738 a: { 1739 b: { 1740 c: { 1741 C: 1 1742 } 1743 } 1744 } 1745 for k, _ in 〈0;a〉 { 1746 a: { 1747 〈2;k〉: { 1748 c: { 1749 D: 2 1750 } 1751 } 1752 } 1753 } 1754 } 1755 } 1756 } 1757 ok: { 1758 t9: { 1759 c: 〈0;#R〉 1760 c: [ 1761 { 1762 b: int 1763 }, 1764 ] 1765 #R: [ 1766 ..., 1767 ] 1768 } 1769 } 1770 ok: { 1771 t10: { 1772 #A: _ 1773 l: 〈0;#A〉 1774 l: { 1775 f: "hi" 1776 } 1777 } 1778 } 1779 ok: { 1780 t11: { 1781 #A: { 1782 f: { 1783 ... 1784 } 1785 } 1786 #A1: { 1787 〈1;#A〉 1788 } 1789 s: { 1790 [string]: 〈1;#A1〉 1791 } 1792 s: { 1793 foo: { 1794 f: { 1795 d: { 1796 foo: "bar" 1797 } 1798 } 1799 } 1800 } 1801 } 1802 } 1803 ok: { 1804 t12: { 1805 #T: { 1806 a: { 1807 b: 1 1808 } 1809 } 1810 W: { 1811 { 1812 〈2;#T〉 1813 } 1814 b: { 1815 c: 2 1816 } 1817 } 1818 } 1819 } 1820 ok: { 1821 t13: { 1822 #A: { 1823 〈1;Common〉 1824 _ 1825 } 1826 Common: {} 1827 x: 〈0;#A〉 1828 x: { 1829 c: int 1830 } 1831 } 1832 } 1833 ok: { 1834 t14: { 1835 #A: { 1836 〈1;Common〉 1837 ... 1838 } 1839 Common: {} 1840 x: 〈0;#A〉 1841 x: { 1842 c: int 1843 } 1844 } 1845 } 1846 err: { 1847 t1: { 1848 #D: (_ & { 1849 a: 2 1850 }) 1851 a: 〈0;#D〉 1852 a: { 1853 disallowed: 1 1854 } 1855 } 1856 } 1857 err: { 1858 t2: { 1859 #S: { 1860 { 1861 c: { 1862 d: 1 1863 } 1864 } 1865 } 1866 V: 〈0;#S〉 1867 V: { 1868 c: { 1869 e: 1 1870 } 1871 } 1872 } 1873 } 1874 err: { 1875 t3: { 1876 p1: { 1877 #D: {} 1878 a: 〈0;#D〉 1879 a: { 1880 c: "C" 1881 } 1882 } 1883 } 1884 } 1885 err: { 1886 t3: { 1887 p2: { 1888 #D: { 1889 b: {} 1890 } 1891 a: 〈0;#D〉 1892 a: { 1893 b: { 1894 c: "C" 1895 } 1896 } 1897 } 1898 } 1899 } 1900 err: { 1901 t4: { 1902 a: 〈0;#A〉 1903 #A: { 1904 b: { 1905 f: 1 1906 } 1907 } 1908 a: { 1909 b: { 1910 h: 1 1911 } 1912 } 1913 } 1914 } 1915 err: { 1916 t5: { 1917 a: { 1918 〈1;#A〉 1919 〈1;#B〉 1920 } 1921 #A: { 1922 b: { 1923 f: 1 1924 } 1925 } 1926 #B: { 1927 b: { 1928 g: 1 1929 } 1930 } 1931 b: 〈0;a〉 1932 b: { 1933 b: { 1934 h: 1 1935 } 1936 } 1937 } 1938 } 1939 err: { 1940 t6: { 1941 a: { 1942 〈1;#A〉 1943 〈1;#B〉 1944 } 1945 #A: { 1946 b: { 1947 c: { 1948 d: { 1949 e: { 1950 f: 1 1951 } 1952 } 1953 } 1954 } 1955 } 1956 #B: { 1957 b: { 1958 c: { 1959 d: { 1960 e: { 1961 g: 1 1962 } 1963 } 1964 } 1965 } 1966 } 1967 b: 〈0;a〉 1968 b: { 1969 b: { 1970 c: { 1971 d: { 1972 e: { 1973 h: 1 1974 } 1975 } 1976 } 1977 } 1978 } 1979 } 1980 } 1981 err: { 1982 t7: { 1983 #D: (_ & { 1984 a: 2 1985 }) 1986 a: 〈0;#D〉 1987 a: { 1988 b: 1 1989 } 1990 } 1991 } 1992 err: { 1993 t8: { 1994 #S: { 1995 { 1996 c: { 1997 d: 1 1998 } 1999 } 2000 } 2001 V: 〈0;#S〉 2002 V: { 2003 c: { 2004 e: 1 2005 } 2006 } 2007 } 2008 } 2009 } 2010 --- issue1830.cue 2011 { 2012 issue1830: { 2013 #x: { 2014 y: { 2015 z?: { 2016 name: string 2017 } 2018 } 2019 } 2020 egs: { 2021 x1: ((〈1;#x〉 & { 2022 y: { 2023 z: _ 2024 } 2025 }).y.z & { 2026 name: "blah" 2027 age1: 5 2028 }) 2029 x2: ((〈1;#x〉.y & { 2030 z: _ 2031 }).z & { 2032 name: "blah" 2033 age2: 5 2034 }) 2035 } 2036 } 2037 }