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