cuelang.org/go@v0.10.1/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 -- out/eval/stats -- 45 Leaks: 39 46 Freed: 160 47 Reused: 150 48 Allocs: 49 49 Retain: 40 50 51 Unifications: 185 52 Conjuncts: 365 53 Disjuncts: 190 54 -- out/evalalpha -- 55 Errors: 56 b.x: field not allowed: 57 ./in.cue:1:4 58 ./in.cue:5:9 59 60 Result: 61 (_|_){ 62 // [eval] 63 a: (#struct){ 64 a: (struct){ 65 b: (int){ int } 66 } 67 } 68 b: (_|_){ 69 // [eval] 70 x: (_|_){ 71 // [eval] b.x: field not allowed: 72 // ./in.cue:1:4 73 // ./in.cue:5:9 74 } 75 a: (struct){ 76 b: (int){ int } 77 } 78 } 79 c: (#struct){ 80 a: (struct){ 81 c: (int){ int } 82 b: (int){ int } 83 } 84 } 85 inDisjunctions: (struct){ 86 x: (struct){ 87 socket: (#struct){ 88 string: (#struct){ |((#struct){ 89 a: (#struct){ 90 b: (bool){ true } 91 } 92 let X#1 = (#struct){ 93 b: (bool){ true } 94 } 95 uint: (#struct){ 96 a: (#struct){ 97 b: (bool){ true } 98 } 99 } 100 }, (#struct){ 101 a: (#struct){ 102 b: (bool){ true } 103 } 104 let X#1 = (#struct){ 105 b: (bool){ true } 106 } 107 string: (#struct){ 108 a: (#struct){ 109 b: (bool){ true } 110 } 111 } 112 }) } 113 } 114 syslog: (#struct){ 115 xxx: (#struct){ |((#struct){ 116 a: (#struct){ 117 b: (bool){ true } 118 } 119 let X#1 = (#struct){ 120 b: (bool){ true } 121 } 122 uint: (#struct){ 123 a: (#struct){ 124 b: (bool){ true } 125 } 126 } 127 }, (#struct){ 128 a: (#struct){ 129 b: (bool){ true } 130 } 131 let X#1 = (#struct){ 132 b: (bool){ true } 133 } 134 string: (#struct){ 135 a: (#struct){ 136 b: (bool){ true } 137 } 138 } 139 }) } 140 string: (#struct){ |((#struct){ 141 a: (#struct){ 142 b: (bool){ true } 143 } 144 let X#1 = (#struct){ 145 b: (bool){ true } 146 } 147 uint: (#struct){ 148 a: (#struct){ 149 b: (bool){ true } 150 } 151 } 152 }, (#struct){ 153 a: (#struct){ 154 b: (bool){ true } 155 } 156 let X#1 = (#struct){ 157 b: (bool){ true } 158 } 159 string: (#struct){ 160 a: (#struct){ 161 b: (bool){ true } 162 } 163 } 164 }) } 165 } 166 } 167 #Def: (#struct){ 168 } 169 } 170 issue642: (struct){ 171 test: (#struct){ 172 a: (struct){ 173 x: (_){ _ } 174 y: (_){ _ } 175 } 176 b: (struct){ 177 x: (_){ _ } 178 y: (_){ _ } 179 } 180 } 181 } 182 withSubfields: (struct){ 183 test: (#struct){ 184 a: (struct){ 185 x: (_){ _ } 186 y: (_){ _ } 187 } 188 b: (struct){ 189 x: (_){ _ } 190 y: (_){ _ } 191 } 192 } 193 } 194 } 195 -- diff/-out/evalalpha<==>+out/eval -- 196 diff old new 197 --- old 198 +++ new 199 @@ -1,7 +1,6 @@ 200 Errors: 201 b.x: field not allowed: 202 - ./in.cue:1:10 203 - ./in.cue:5:4 204 + ./in.cue:1:4 205 ./in.cue:5:9 206 207 Result: 208 @@ -14,20 +13,19 @@ 209 } 210 b: (_|_){ 211 // [eval] 212 - a: (struct){ 213 - b: (int){ int } 214 - } 215 x: (_|_){ 216 // [eval] b.x: field not allowed: 217 - // ./in.cue:1:10 218 - // ./in.cue:5:4 219 + // ./in.cue:1:4 220 // ./in.cue:5:9 221 } 222 + a: (struct){ 223 + b: (int){ int } 224 + } 225 } 226 c: (#struct){ 227 a: (struct){ 228 - b: (int){ int } 229 c: (int){ int } 230 + b: (int){ int } 231 } 232 } 233 inDisjunctions: (struct){ 234 @@ -60,42 +58,50 @@ 235 }) } 236 } 237 syslog: (#struct){ 238 - string: (#struct){ |((#struct){ 239 - a: (#struct){ 240 - b: (bool){ true } 241 - } 242 - let X#1multi = 〈0;a〉 243 - uint: (#struct){ 244 - a: (#struct){ 245 - b: (bool){ true } 246 - } 247 - } 248 - }, (#struct){ 249 - a: (#struct){ 250 - b: (bool){ true } 251 - } 252 - let X#1multi = 〈0;a〉 253 - string: (#struct){ 254 - a: (#struct){ 255 - b: (bool){ true } 256 - } 257 - } 258 - }) } 259 xxx: (#struct){ |((#struct){ 260 a: (#struct){ 261 b: (bool){ true } 262 } 263 - let X#1multi = 〈0;a〉 264 - uint: (#struct){ 265 - a: (#struct){ 266 - b: (bool){ true } 267 - } 268 - } 269 - }, (#struct){ 270 - a: (#struct){ 271 - b: (bool){ true } 272 - } 273 - let X#1multi = 〈0;a〉 274 + let X#1 = (#struct){ 275 + b: (bool){ true } 276 + } 277 + uint: (#struct){ 278 + a: (#struct){ 279 + b: (bool){ true } 280 + } 281 + } 282 + }, (#struct){ 283 + a: (#struct){ 284 + b: (bool){ true } 285 + } 286 + let X#1 = (#struct){ 287 + b: (bool){ true } 288 + } 289 + string: (#struct){ 290 + a: (#struct){ 291 + b: (bool){ true } 292 + } 293 + } 294 + }) } 295 + string: (#struct){ |((#struct){ 296 + a: (#struct){ 297 + b: (bool){ true } 298 + } 299 + let X#1 = (#struct){ 300 + b: (bool){ true } 301 + } 302 + uint: (#struct){ 303 + a: (#struct){ 304 + b: (bool){ true } 305 + } 306 + } 307 + }, (#struct){ 308 + a: (#struct){ 309 + b: (bool){ true } 310 + } 311 + let X#1 = (#struct){ 312 + b: (bool){ true } 313 + } 314 string: (#struct){ 315 a: (#struct){ 316 b: (bool){ true } 317 -- diff/todo/p3 -- 318 Reordering 319 Let differs. 320 -- out/eval -- 321 Errors: 322 b.x: field not allowed: 323 ./in.cue:1:10 324 ./in.cue:5:4 325 ./in.cue:5:9 326 327 Result: 328 (_|_){ 329 // [eval] 330 a: (#struct){ 331 a: (struct){ 332 b: (int){ int } 333 } 334 } 335 b: (_|_){ 336 // [eval] 337 a: (struct){ 338 b: (int){ int } 339 } 340 x: (_|_){ 341 // [eval] b.x: field not allowed: 342 // ./in.cue:1:10 343 // ./in.cue:5:4 344 // ./in.cue:5:9 345 } 346 } 347 c: (#struct){ 348 a: (struct){ 349 b: (int){ int } 350 c: (int){ int } 351 } 352 } 353 inDisjunctions: (struct){ 354 x: (struct){ 355 socket: (#struct){ 356 string: (#struct){ |((#struct){ 357 a: (#struct){ 358 b: (bool){ true } 359 } 360 let X#1 = (#struct){ 361 b: (bool){ true } 362 } 363 uint: (#struct){ 364 a: (#struct){ 365 b: (bool){ true } 366 } 367 } 368 }, (#struct){ 369 a: (#struct){ 370 b: (bool){ true } 371 } 372 let X#1 = (#struct){ 373 b: (bool){ true } 374 } 375 string: (#struct){ 376 a: (#struct){ 377 b: (bool){ true } 378 } 379 } 380 }) } 381 } 382 syslog: (#struct){ 383 string: (#struct){ |((#struct){ 384 a: (#struct){ 385 b: (bool){ true } 386 } 387 let X#1multi = 〈0;a〉 388 uint: (#struct){ 389 a: (#struct){ 390 b: (bool){ true } 391 } 392 } 393 }, (#struct){ 394 a: (#struct){ 395 b: (bool){ true } 396 } 397 let X#1multi = 〈0;a〉 398 string: (#struct){ 399 a: (#struct){ 400 b: (bool){ true } 401 } 402 } 403 }) } 404 xxx: (#struct){ |((#struct){ 405 a: (#struct){ 406 b: (bool){ true } 407 } 408 let X#1multi = 〈0;a〉 409 uint: (#struct){ 410 a: (#struct){ 411 b: (bool){ true } 412 } 413 } 414 }, (#struct){ 415 a: (#struct){ 416 b: (bool){ true } 417 } 418 let X#1multi = 〈0;a〉 419 string: (#struct){ 420 a: (#struct){ 421 b: (bool){ true } 422 } 423 } 424 }) } 425 } 426 } 427 #Def: (#struct){ 428 } 429 } 430 issue642: (struct){ 431 test: (#struct){ 432 a: (struct){ 433 x: (_){ _ } 434 y: (_){ _ } 435 } 436 b: (struct){ 437 x: (_){ _ } 438 y: (_){ _ } 439 } 440 } 441 } 442 withSubfields: (struct){ 443 test: (#struct){ 444 a: (struct){ 445 x: (_){ _ } 446 y: (_){ _ } 447 } 448 b: (struct){ 449 x: (_){ _ } 450 y: (_){ _ } 451 } 452 } 453 } 454 } 455 -- out/compile -- 456 --- in.cue 457 { 458 a: close({ 459 a: { 460 b: int 461 } 462 }) 463 b: (〈0;a〉 & { 464 x: int 465 }) 466 c: (〈0;a〉 & { 467 a: { 468 c: int 469 } 470 }) 471 inDisjunctions: { 472 x: { 473 [string]: 〈1;#Def〉 474 } 475 #Def: { 476 [string]: { 477 a: { 478 b: true 479 } 480 let X#1 = 〈0;a〉 481 (close({ 482 uint: { 483 a: { 484 b: 〈3;let X#1〉.b 485 } 486 } 487 })|close({ 488 string: { 489 a: { 490 b: true 491 } 492 } 493 })) 494 } 495 } 496 x: { 497 socket: { 498 string: {} 499 } 500 } 501 x: { 502 syslog: 〈1;x〉.socket 503 } 504 x: { 505 syslog: { 506 xxx: {} 507 } 508 } 509 } 510 issue642: { 511 test: close(({ 512 a: _ 513 b: { 514 x: _ 515 } 516 } & { 517 [string]: { 518 y: _ 519 } 520 })) 521 test: { 522 a: { 523 x: _ 524 } 525 } 526 test: { 527 b: { 528 x: _ 529 } 530 } 531 } 532 withSubfields: { 533 test: close({ 534 a: _ 535 b: { 536 x: _ 537 } 538 [string]: { 539 y: _ 540 } 541 }) 542 test: { 543 a: { 544 x: _ 545 } 546 } 547 test: { 548 b: { 549 x: _ 550 } 551 } 552 } 553 }