cuelang.org/go@v0.13.0/cue/testdata/builtins/closed.txtar (about) 1 -- in.cue -- 2 a: close({ 3 a: b: int 4 }) 5 6 b: a & {x: int} // err 7 c: a & {a: c: int} // okay (non-recursive close) 8 9 inDisjunctions: { 10 x: [string]: #Def 11 #Def: [string]: { 12 a: b: true 13 let X = a 14 close({uint: a: b: X.b}) | close({string: a: b: true}) 15 } 16 x: socket: string: {} 17 x: syslog: x.socket 18 x: syslog: xxx: {} 19 } 20 21 issue642: { 22 test: close({ 23 a: _ 24 b: x: _ 25 } & { 26 [string]: y: _ 27 }) 28 29 test: a: x: _ 30 test: b: x: _ 31 } 32 33 // Issue 642 34 withSubfields: { 35 test: close({ 36 a: _ 37 b: x: _ 38 [string]: y: _ 39 }) 40 41 test: a: x: _ 42 test: b: x: _ 43 } 44 45 issue3572: { 46 t1: close({...}) & {a: 5} 47 48 e: close({...}) 49 50 t2: e & {a: 5} 51 } 52 53 issue3580: { 54 x: close({ 55 a: _ 56 b: x.a 57 }) 58 } 59 -- out/evalalpha/stats -- 60 Leaks: 378 61 Freed: 0 62 Reused: 0 63 Allocs: 378 64 Retain: 0 65 66 Unifications: 179 67 Conjuncts: 595 68 Disjuncts: 24 69 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 70 diff old new 71 --- old 72 +++ new 73 @@ -1,9 +1,9 @@ 74 -Leaks: 43 75 -Freed: 170 76 -Reused: 164 77 -Allocs: 49 78 -Retain: 44 79 +Leaks: 378 80 +Freed: 0 81 +Reused: 0 82 +Allocs: 378 83 +Retain: 0 84 85 -Unifications: 199 86 -Conjuncts: 389 87 -Disjuncts: 204 88 +Unifications: 179 89 +Conjuncts: 595 90 +Disjuncts: 24 91 -- out/eval/stats -- 92 Leaks: 43 93 Freed: 170 94 Reused: 164 95 Allocs: 49 96 Retain: 44 97 98 Unifications: 199 99 Conjuncts: 389 100 Disjuncts: 204 101 -- out/evalalpha -- 102 Errors: 103 b.x: field not allowed: 104 ./in.cue:5:9 105 106 Result: 107 (_|_){ 108 // [eval] 109 a: (#struct){ 110 a: (struct){ 111 b: (int){ int } 112 } 113 } 114 b: (_|_){ 115 // [eval] 116 x: (_|_){ 117 // [eval] b.x: field not allowed: 118 // ./in.cue:5:9 119 } 120 a: (struct){ 121 b: (int){ int } 122 } 123 } 124 c: (#struct){ 125 a: (struct){ 126 c: (int){ int } 127 b: (int){ int } 128 } 129 } 130 inDisjunctions: (struct){ 131 x: (struct){ 132 socket: (#struct){ 133 string: (#struct){ |((#struct){ 134 a: (#struct){ 135 b: (bool){ true } 136 } 137 let X#1 = ~(inDisjunctions.x.socket.string.a) 138 uint: (#struct){ 139 a: (#struct){ 140 b: (bool){ true } 141 } 142 } 143 }, (#struct){ 144 a: (#struct){ 145 b: (bool){ true } 146 } 147 let X#1 = ~(inDisjunctions.x.socket.string.a) 148 string: (#struct){ 149 a: (#struct){ 150 b: (bool){ true } 151 } 152 } 153 }) } 154 } 155 syslog: (#struct){ 156 xxx: (#struct){ |((#struct){ 157 a: (#struct){ 158 b: (bool){ true } 159 } 160 let X#1 = ~(inDisjunctions.x.syslog.xxx.a) 161 uint: (#struct){ 162 a: (#struct){ 163 b: (bool){ true } 164 } 165 } 166 }, (#struct){ 167 a: (#struct){ 168 b: (bool){ true } 169 } 170 let X#1 = ~(inDisjunctions.x.syslog.xxx.a) 171 string: (#struct){ 172 a: (#struct){ 173 b: (bool){ true } 174 } 175 } 176 }) } 177 string: (#struct){ |((#struct){ 178 a: (#struct){ 179 b: (bool){ true } 180 } 181 let X#1 = ~(inDisjunctions.x.syslog.string.a) 182 uint: (#struct){ 183 a: (#struct){ 184 b: (bool){ true } 185 } 186 } 187 }, (#struct){ 188 a: (#struct){ 189 b: (bool){ true } 190 } 191 let X#1 = ~(inDisjunctions.x.syslog.string.a) 192 string: (#struct){ 193 a: (#struct){ 194 b: (bool){ true } 195 } 196 } 197 }) } 198 } 199 } 200 #Def: (#struct){ 201 } 202 } 203 issue642: (struct){ 204 test: (#struct){ 205 a: (struct){ 206 x: (_){ _ } 207 y: (_){ _ } 208 } 209 b: (struct){ 210 x: (_){ _ } 211 y: (_){ _ } 212 } 213 } 214 } 215 withSubfields: (struct){ 216 test: (#struct){ 217 a: (struct){ 218 x: (_){ _ } 219 y: (_){ _ } 220 } 221 b: (struct){ 222 x: (_){ _ } 223 y: (_){ _ } 224 } 225 } 226 } 227 issue3572: (struct){ 228 t1: (#struct){ 229 a: (int){ 5 } 230 } 231 e: (#struct){ 232 } 233 t2: (#struct){ 234 a: (int){ 5 } 235 } 236 } 237 issue3580: (struct){ 238 x: (#struct){ 239 a: (_){ _ } 240 b: (_){ _ } 241 } 242 } 243 } 244 -- diff/-out/evalalpha<==>+out/eval -- 245 diff old new 246 --- old 247 +++ new 248 @@ -1,7 +1,5 @@ 249 Errors: 250 b.x: field not allowed: 251 - ./in.cue:1:10 252 - ./in.cue:5:4 253 ./in.cue:5:9 254 255 Result: 256 @@ -14,20 +12,18 @@ 257 } 258 b: (_|_){ 259 // [eval] 260 - a: (struct){ 261 - b: (int){ int } 262 - } 263 x: (_|_){ 264 // [eval] b.x: field not allowed: 265 - // ./in.cue:1:10 266 - // ./in.cue:5:4 267 // ./in.cue:5:9 268 } 269 + a: (struct){ 270 + b: (int){ int } 271 + } 272 } 273 c: (#struct){ 274 a: (struct){ 275 - b: (int){ int } 276 c: (int){ int } 277 + b: (int){ int } 278 } 279 } 280 inDisjunctions: (struct){ 281 @@ -37,21 +33,17 @@ 282 a: (#struct){ 283 b: (bool){ true } 284 } 285 - let X#1 = (#struct){ 286 - b: (bool){ true } 287 - } 288 - uint: (#struct){ 289 - a: (#struct){ 290 - b: (bool){ true } 291 - } 292 - } 293 - }, (#struct){ 294 - a: (#struct){ 295 - b: (bool){ true } 296 - } 297 - let X#1 = (#struct){ 298 - b: (bool){ true } 299 - } 300 + let X#1 = ~(inDisjunctions.x.socket.string.a) 301 + uint: (#struct){ 302 + a: (#struct){ 303 + b: (bool){ true } 304 + } 305 + } 306 + }, (#struct){ 307 + a: (#struct){ 308 + b: (bool){ true } 309 + } 310 + let X#1 = ~(inDisjunctions.x.socket.string.a) 311 string: (#struct){ 312 a: (#struct){ 313 b: (bool){ true } 314 @@ -60,42 +52,42 @@ 315 }) } 316 } 317 syslog: (#struct){ 318 - string: (#struct){ |((#struct){ 319 - a: (#struct){ 320 - b: (bool){ true } 321 - } 322 - let X#1multi = 〈0;a〉 323 - uint: (#struct){ 324 - a: (#struct){ 325 - b: (bool){ true } 326 - } 327 - } 328 - }, (#struct){ 329 - a: (#struct){ 330 - b: (bool){ true } 331 - } 332 - let X#1multi = 〈0;a〉 333 - string: (#struct){ 334 - a: (#struct){ 335 - b: (bool){ true } 336 - } 337 - } 338 - }) } 339 xxx: (#struct){ |((#struct){ 340 a: (#struct){ 341 b: (bool){ true } 342 } 343 - let X#1multi = 〈0;a〉 344 - uint: (#struct){ 345 - a: (#struct){ 346 - b: (bool){ true } 347 - } 348 - } 349 - }, (#struct){ 350 - a: (#struct){ 351 - b: (bool){ true } 352 - } 353 - let X#1multi = 〈0;a〉 354 + let X#1 = ~(inDisjunctions.x.syslog.xxx.a) 355 + uint: (#struct){ 356 + a: (#struct){ 357 + b: (bool){ true } 358 + } 359 + } 360 + }, (#struct){ 361 + a: (#struct){ 362 + b: (bool){ true } 363 + } 364 + let X#1 = ~(inDisjunctions.x.syslog.xxx.a) 365 + string: (#struct){ 366 + a: (#struct){ 367 + b: (bool){ true } 368 + } 369 + } 370 + }) } 371 + string: (#struct){ |((#struct){ 372 + a: (#struct){ 373 + b: (bool){ true } 374 + } 375 + let X#1 = ~(inDisjunctions.x.syslog.string.a) 376 + uint: (#struct){ 377 + a: (#struct){ 378 + b: (bool){ true } 379 + } 380 + } 381 + }, (#struct){ 382 + a: (#struct){ 383 + b: (bool){ true } 384 + } 385 + let X#1 = ~(inDisjunctions.x.syslog.string.a) 386 string: (#struct){ 387 a: (#struct){ 388 b: (bool){ true } 389 -- diff/todo/p3 -- 390 Reordering 391 Let differs. 392 -- out/eval -- 393 Errors: 394 b.x: field not allowed: 395 ./in.cue:1:10 396 ./in.cue:5:4 397 ./in.cue:5:9 398 399 Result: 400 (_|_){ 401 // [eval] 402 a: (#struct){ 403 a: (struct){ 404 b: (int){ int } 405 } 406 } 407 b: (_|_){ 408 // [eval] 409 a: (struct){ 410 b: (int){ int } 411 } 412 x: (_|_){ 413 // [eval] b.x: field not allowed: 414 // ./in.cue:1:10 415 // ./in.cue:5:4 416 // ./in.cue:5:9 417 } 418 } 419 c: (#struct){ 420 a: (struct){ 421 b: (int){ int } 422 c: (int){ int } 423 } 424 } 425 inDisjunctions: (struct){ 426 x: (struct){ 427 socket: (#struct){ 428 string: (#struct){ |((#struct){ 429 a: (#struct){ 430 b: (bool){ true } 431 } 432 let X#1 = (#struct){ 433 b: (bool){ true } 434 } 435 uint: (#struct){ 436 a: (#struct){ 437 b: (bool){ true } 438 } 439 } 440 }, (#struct){ 441 a: (#struct){ 442 b: (bool){ true } 443 } 444 let X#1 = (#struct){ 445 b: (bool){ true } 446 } 447 string: (#struct){ 448 a: (#struct){ 449 b: (bool){ true } 450 } 451 } 452 }) } 453 } 454 syslog: (#struct){ 455 string: (#struct){ |((#struct){ 456 a: (#struct){ 457 b: (bool){ true } 458 } 459 let X#1multi = 〈0;a〉 460 uint: (#struct){ 461 a: (#struct){ 462 b: (bool){ true } 463 } 464 } 465 }, (#struct){ 466 a: (#struct){ 467 b: (bool){ true } 468 } 469 let X#1multi = 〈0;a〉 470 string: (#struct){ 471 a: (#struct){ 472 b: (bool){ true } 473 } 474 } 475 }) } 476 xxx: (#struct){ |((#struct){ 477 a: (#struct){ 478 b: (bool){ true } 479 } 480 let X#1multi = 〈0;a〉 481 uint: (#struct){ 482 a: (#struct){ 483 b: (bool){ true } 484 } 485 } 486 }, (#struct){ 487 a: (#struct){ 488 b: (bool){ true } 489 } 490 let X#1multi = 〈0;a〉 491 string: (#struct){ 492 a: (#struct){ 493 b: (bool){ true } 494 } 495 } 496 }) } 497 } 498 } 499 #Def: (#struct){ 500 } 501 } 502 issue642: (struct){ 503 test: (#struct){ 504 a: (struct){ 505 x: (_){ _ } 506 y: (_){ _ } 507 } 508 b: (struct){ 509 x: (_){ _ } 510 y: (_){ _ } 511 } 512 } 513 } 514 withSubfields: (struct){ 515 test: (#struct){ 516 a: (struct){ 517 x: (_){ _ } 518 y: (_){ _ } 519 } 520 b: (struct){ 521 x: (_){ _ } 522 y: (_){ _ } 523 } 524 } 525 } 526 issue3572: (struct){ 527 t1: (#struct){ 528 a: (int){ 5 } 529 } 530 e: (#struct){ 531 } 532 t2: (#struct){ 533 a: (int){ 5 } 534 } 535 } 536 issue3580: (struct){ 537 x: (#struct){ 538 a: (_){ _ } 539 b: (_){ _ } 540 } 541 } 542 } 543 -- out/compile -- 544 --- in.cue 545 { 546 a: close({ 547 a: { 548 b: int 549 } 550 }) 551 b: (〈0;a〉 & { 552 x: int 553 }) 554 c: (〈0;a〉 & { 555 a: { 556 c: int 557 } 558 }) 559 inDisjunctions: { 560 x: { 561 [string]: 〈1;#Def〉 562 } 563 #Def: { 564 [string]: { 565 a: { 566 b: true 567 } 568 let X#1 = 〈0;a〉 569 (close({ 570 uint: { 571 a: { 572 b: 〈3;let X#1〉.b 573 } 574 } 575 })|close({ 576 string: { 577 a: { 578 b: true 579 } 580 } 581 })) 582 } 583 } 584 x: { 585 socket: { 586 string: {} 587 } 588 } 589 x: { 590 syslog: 〈1;x〉.socket 591 } 592 x: { 593 syslog: { 594 xxx: {} 595 } 596 } 597 } 598 issue642: { 599 test: close(({ 600 a: _ 601 b: { 602 x: _ 603 } 604 } & { 605 [string]: { 606 y: _ 607 } 608 })) 609 test: { 610 a: { 611 x: _ 612 } 613 } 614 test: { 615 b: { 616 x: _ 617 } 618 } 619 } 620 withSubfields: { 621 test: close({ 622 a: _ 623 b: { 624 x: _ 625 } 626 [string]: { 627 y: _ 628 } 629 }) 630 test: { 631 a: { 632 x: _ 633 } 634 } 635 test: { 636 b: { 637 x: _ 638 } 639 } 640 } 641 issue3572: { 642 t1: (close({ 643 ... 644 }) & { 645 a: 5 646 }) 647 e: close({ 648 ... 649 }) 650 t2: (〈0;e〉 & { 651 a: 5 652 }) 653 } 654 issue3580: { 655 x: close({ 656 a: _ 657 b: 〈1;x〉.a 658 }) 659 } 660 }