cuelang.org/go@v0.13.0/cue/testdata/eval/issue2146.txtar (about) 1 // Issue #2146 2 // 3 // Ensure that let expressions are uniqued not only per Environment, but also 4 // per arc. This is relevant for disjunctions. Without it, an incorrect 5 // result may be cached for an arbitrary Environment. 6 -- in.cue -- 7 p1: { 8 #A: { 9 x?: int 10 y?: int 11 12 let list = [x, y] 13 all: [for v in list if v != _|_ {v}] 14 15 *{ 16 x?: _|_ 17 y: 1 18 } | _ 19 } 20 21 a: #A & { x: 3 } 22 b: #A & a 23 } 24 p2: { 25 #A: { 26 x?: int 27 y?: int 28 29 let list = [x, y] 30 all: [for v in list if v != _|_ {v}] 31 32 _ | *{ 33 x?: _|_ 34 y: 1 35 } 36 } 37 38 a: #A & { x: 3, y: 2 } 39 b: #A & a 40 } 41 42 -- out/evalalpha/stats -- 43 Leaks: 139 44 Freed: 0 45 Reused: 0 46 Allocs: 139 47 Retain: 0 48 49 Unifications: 79 50 Conjuncts: 157 51 Disjuncts: 12 52 53 CloseIDElems: 120 54 NumCloseIDs: 42 55 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 56 diff old new 57 --- old 58 +++ new 59 @@ -1,9 +1,12 @@ 60 -Leaks: 18 61 -Freed: 171 62 -Reused: 163 63 -Allocs: 26 64 -Retain: 18 65 - 66 -Unifications: 173 67 -Conjuncts: 557 68 -Disjuncts: 189 69 +Leaks: 139 70 +Freed: 0 71 +Reused: 0 72 +Allocs: 139 73 +Retain: 0 74 + 75 +Unifications: 79 76 +Conjuncts: 157 77 +Disjuncts: 12 78 + 79 +CloseIDElems: 120 80 +NumCloseIDs: 42 81 -- out/eval/stats -- 82 Leaks: 18 83 Freed: 171 84 Reused: 163 85 Allocs: 26 86 Retain: 18 87 88 Unifications: 173 89 Conjuncts: 557 90 Disjuncts: 189 91 -- out/evalalpha -- 92 (struct){ 93 p1: (struct){ 94 #A: (#struct){ |(*(#struct){ 95 x?: (_|_){ 96 // [user] explicit error (_|_ literal) in source: 97 // ./in.cue:10:8 98 } 99 y: (int){ 1 } 100 let list#1 = (#list){ 101 0: (_|_){ 102 // [incomplete] p1.#A.list.0: cannot reference optional field: x: 103 // ./in.cue:6:15 104 } 105 1: (int){ 1 } 106 } 107 all: (#list){ 108 0: (int){ 1 } 109 } 110 }, (#struct){ 111 x?: (int){ int } 112 y?: (int){ int } 113 let list#1 = (#list){ 114 0: (_|_){ 115 // [incomplete] p1.#A.list.0: cannot reference optional field: x: 116 // ./in.cue:6:15 117 } 118 1: (_|_){ 119 // [incomplete] p1.#A.list.1: cannot reference optional field: y: 120 // ./in.cue:6:18 121 } 122 } 123 all: (#list){ 124 } 125 }) } 126 a: (#struct){ 127 x: (int){ 3 } 128 y?: (int){ int } 129 let list#1 = (#list){ 130 0: (int){ 3 } 131 1: (_|_){ 132 // [incomplete] p1.a.list.1: cannot reference optional field: y: 133 // ./in.cue:6:18 134 } 135 } 136 all: (#list){ 137 0: (int){ 3 } 138 } 139 } 140 b: (#struct){ 141 x: (int){ 3 } 142 y?: (int){ int } 143 let list#1 = (#list){ 144 0: (int){ 3 } 145 1: (_|_){ 146 // [incomplete] p1.b.list.1: cannot reference optional field: y: 147 // ./in.cue:6:18 148 } 149 } 150 all: (#list){ 151 0: (int){ 3 } 152 } 153 } 154 } 155 p2: (struct){ 156 #A: (#struct){ |(*(#struct){ 157 x?: (_|_){ 158 // [user] explicit error (_|_ literal) in source: 159 // ./in.cue:27:8 160 } 161 y: (int){ 1 } 162 let list#2 = (#list){ 163 0: (_|_){ 164 // [incomplete] p2.#A.list.0: cannot reference optional field: x: 165 // ./in.cue:23:15 166 } 167 1: (int){ 1 } 168 } 169 all: (#list){ 170 0: (int){ 1 } 171 } 172 }, (#struct){ 173 x?: (int){ int } 174 y?: (int){ int } 175 let list#2 = (#list){ 176 0: (_|_){ 177 // [incomplete] p2.#A.list.0: cannot reference optional field: x: 178 // ./in.cue:23:15 179 } 180 1: (_|_){ 181 // [incomplete] p2.#A.list.1: cannot reference optional field: y: 182 // ./in.cue:23:18 183 } 184 } 185 all: (#list){ 186 } 187 }) } 188 a: (#struct){ 189 x: (int){ 3 } 190 y: (int){ 2 } 191 let list#2 = (#list){ 192 0: (int){ 3 } 193 1: (int){ 2 } 194 } 195 all: (#list){ 196 0: (int){ 3 } 197 1: (int){ 2 } 198 } 199 } 200 b: (#struct){ 201 x: (int){ 3 } 202 y: (int){ 2 } 203 let list#2 = (#list){ 204 0: (int){ 3 } 205 1: (int){ 2 } 206 } 207 all: (#list){ 208 0: (int){ 3 } 209 1: (int){ 2 } 210 } 211 } 212 } 213 } 214 -- diff/-out/evalalpha<==>+out/eval -- 215 diff old new 216 --- old 217 +++ new 218 @@ -49,10 +49,13 @@ 219 b: (#struct){ 220 x: (int){ 3 } 221 y?: (int){ int } 222 - let list#1multi = [ 223 - 〈1;x〉, 224 - 〈1;y〉, 225 - ] 226 + let list#1 = (#list){ 227 + 0: (int){ 3 } 228 + 1: (_|_){ 229 + // [incomplete] p1.b.list.1: cannot reference optional field: y: 230 + // ./in.cue:6:18 231 + } 232 + } 233 all: (#list){ 234 0: (int){ 3 } 235 } 236 @@ -106,10 +109,10 @@ 237 b: (#struct){ 238 x: (int){ 3 } 239 y: (int){ 2 } 240 - let list#2multi = [ 241 - 〈1;x〉, 242 - 〈1;y〉, 243 - ] 244 + let list#2 = (#list){ 245 + 0: (int){ 3 } 246 + 1: (int){ 2 } 247 + } 248 all: (#list){ 249 0: (int){ 3 } 250 1: (int){ 2 } 251 -- out/eval -- 252 (struct){ 253 p1: (struct){ 254 #A: (#struct){ |(*(#struct){ 255 x?: (_|_){ 256 // [user] explicit error (_|_ literal) in source: 257 // ./in.cue:10:8 258 } 259 y: (int){ 1 } 260 let list#1 = (#list){ 261 0: (_|_){ 262 // [incomplete] p1.#A.list.0: cannot reference optional field: x: 263 // ./in.cue:6:15 264 } 265 1: (int){ 1 } 266 } 267 all: (#list){ 268 0: (int){ 1 } 269 } 270 }, (#struct){ 271 x?: (int){ int } 272 y?: (int){ int } 273 let list#1 = (#list){ 274 0: (_|_){ 275 // [incomplete] p1.#A.list.0: cannot reference optional field: x: 276 // ./in.cue:6:15 277 } 278 1: (_|_){ 279 // [incomplete] p1.#A.list.1: cannot reference optional field: y: 280 // ./in.cue:6:18 281 } 282 } 283 all: (#list){ 284 } 285 }) } 286 a: (#struct){ 287 x: (int){ 3 } 288 y?: (int){ int } 289 let list#1 = (#list){ 290 0: (int){ 3 } 291 1: (_|_){ 292 // [incomplete] p1.a.list.1: cannot reference optional field: y: 293 // ./in.cue:6:18 294 } 295 } 296 all: (#list){ 297 0: (int){ 3 } 298 } 299 } 300 b: (#struct){ 301 x: (int){ 3 } 302 y?: (int){ int } 303 let list#1multi = [ 304 〈1;x〉, 305 〈1;y〉, 306 ] 307 all: (#list){ 308 0: (int){ 3 } 309 } 310 } 311 } 312 p2: (struct){ 313 #A: (#struct){ |(*(#struct){ 314 x?: (_|_){ 315 // [user] explicit error (_|_ literal) in source: 316 // ./in.cue:27:8 317 } 318 y: (int){ 1 } 319 let list#2 = (#list){ 320 0: (_|_){ 321 // [incomplete] p2.#A.list.0: cannot reference optional field: x: 322 // ./in.cue:23:15 323 } 324 1: (int){ 1 } 325 } 326 all: (#list){ 327 0: (int){ 1 } 328 } 329 }, (#struct){ 330 x?: (int){ int } 331 y?: (int){ int } 332 let list#2 = (#list){ 333 0: (_|_){ 334 // [incomplete] p2.#A.list.0: cannot reference optional field: x: 335 // ./in.cue:23:15 336 } 337 1: (_|_){ 338 // [incomplete] p2.#A.list.1: cannot reference optional field: y: 339 // ./in.cue:23:18 340 } 341 } 342 all: (#list){ 343 } 344 }) } 345 a: (#struct){ 346 x: (int){ 3 } 347 y: (int){ 2 } 348 let list#2 = (#list){ 349 0: (int){ 3 } 350 1: (int){ 2 } 351 } 352 all: (#list){ 353 0: (int){ 3 } 354 1: (int){ 2 } 355 } 356 } 357 b: (#struct){ 358 x: (int){ 3 } 359 y: (int){ 2 } 360 let list#2multi = [ 361 〈1;x〉, 362 〈1;y〉, 363 ] 364 all: (#list){ 365 0: (int){ 3 } 366 1: (int){ 2 } 367 } 368 } 369 } 370 } 371 -- out/compile -- 372 --- in.cue 373 { 374 p1: { 375 #A: { 376 x?: int 377 y?: int 378 let list#1 = [ 379 〈1;x〉, 380 〈1;y〉, 381 ] 382 all: [ 383 for _, v in 〈1;let list#1〉 if (〈0;v〉 != _|_(explicit error (_|_ literal) in source)) { 384 〈1;v〉 385 }, 386 ] 387 (*{ 388 x?: _|_(explicit error (_|_ literal) in source) 389 y: 1 390 }|_) 391 } 392 a: (〈0;#A〉 & { 393 x: 3 394 }) 395 b: (〈0;#A〉 & 〈0;a〉) 396 } 397 p2: { 398 #A: { 399 x?: int 400 y?: int 401 let list#2 = [ 402 〈1;x〉, 403 〈1;y〉, 404 ] 405 all: [ 406 for _, v in 〈1;let list#2〉 if (〈0;v〉 != _|_(explicit error (_|_ literal) in source)) { 407 〈1;v〉 408 }, 409 ] 410 (_|*{ 411 x?: _|_(explicit error (_|_ literal) in source) 412 y: 1 413 }) 414 } 415 a: (〈0;#A〉 & { 416 x: 3 417 y: 2 418 }) 419 b: (〈0;#A〉 & 〈0;a〉) 420 } 421 }