this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: lets of comprehensions are multi lets

This fixes a regression of #2218 that was inadvertently
introduced in https://review.gerrithub.io/c/cue-lang/cue/+/551413/5/internal/core/adt/comprehension.go

Issue #2218

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ieccc37c794bfdba9381c441acc93894a528801fb
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557097
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

authored by

Marcel van Lohuizen and committed by
Daniel Martí
43b46748 51237379

+51 -158
+7 -7
cue/testdata/comprehensions/pushdown.txtar
··· 742 742 } 743 743 744 744 -- out/eval/stats -- 745 - Leaks: 14 745 + Leaks: 15 746 746 Freed: 394 747 - Reused: 387 747 + Reused: 388 748 748 Allocs: 21 749 - Retain: 107 749 + Retain: 108 750 750 751 - Unifications: 394 752 - Conjuncts: 638 753 - Disjuncts: 471 751 + Unifications: 395 752 + Conjuncts: 640 753 + Disjuncts: 472 754 754 -- out/eval -- 755 755 Errors: 756 756 embed.fail1.p: field not allowed: ··· 1344 1344 y: (int){ 1 } 1345 1345 } 1346 1346 a: (struct){ 1347 - let x#1 = (int){ 1 } 1347 + let x#1multi = 〈1;v〉 1348 1348 } 1349 1349 } 1350 1350 nestedWithEmbeddingOK: (struct){
+13 -91
cue/testdata/cycle/issue990.txtar
··· 173 173 }) 174 174 } 175 175 -- out/eval/stats -- 176 - Leaks: 0 177 - Freed: 1907 178 - Reused: 1882 176 + Leaks: 6 177 + Freed: 3232 178 + Reused: 3213 179 179 Allocs: 25 180 - Retain: 12 180 + Retain: 26 181 181 182 - Unifications: 1541 183 - Conjuncts: 6931 184 - Disjuncts: 1919 182 + Unifications: 2588 183 + Conjuncts: 12056 184 + Disjuncts: 3258 185 185 -- out/eval -- 186 186 (struct){ 187 187 #AC: (#struct){ ··· 232 232 } 233 233 dict: (#struct){ 234 234 } 235 - let subs#1 = (_){ _ } 235 + let subs#1multi = (〈3;#sub〉 & { 236 + #p: 〈2;rd〉.a 237 + }) 236 238 } 237 239 _test: (struct){ 238 240 c1: (#struct){ ··· 423 425 } 424 426 } 425 427 } 426 - let subs#1 = (#struct){ 427 - #p: (#struct){ 428 - k: (string){ "complex" } 429 - d: (#struct){ 430 - n: (string){ "s2" } 431 - r: (#struct){ 432 - r1: (#struct){ 433 - a: (#struct){ 434 - k: (string){ "simple" } 435 - d: (#struct){ 436 - n: (string){ "c1" } 437 - } 438 - } 439 - } 440 - r2: (#struct){ 441 - a: (#struct){ 442 - k: (string){ "complex" } 443 - d: (#struct){ 444 - n: (string){ "s3" } 445 - r: (#struct){ 446 - r1: (#struct){ 447 - a: (#struct){ 448 - k: (string){ "simple" } 449 - d: (#struct){ 450 - n: (string){ "c1" } 451 - } 452 - } 453 - } 454 - } 455 - } 456 - } 457 - } 458 - } 459 - } 460 - } 461 - dict: (#struct){ 462 - r1: (#struct){ 463 - a: (#struct){ 464 - k: (string){ "simple" } 465 - d: (#struct){ 466 - n: (string){ "c1" } 467 - } 468 - } 469 - } 470 - r2_r1: (#struct){ 471 - a: (#struct){ 472 - k: (string){ "simple" } 473 - d: (#struct){ 474 - n: (string){ "c1" } 475 - } 476 - } 477 - } 478 - } 479 - let subs#1 = (#struct){ 480 - #p: (#struct){ 481 - k: (string){ "complex" } 482 - d: (#struct){ 483 - n: (string){ "s3" } 484 - r: (#struct){ 485 - r1: (#struct){ 486 - a: (#struct){ 487 - k: (string){ "simple" } 488 - d: (#struct){ 489 - n: (string){ "c1" } 490 - } 491 - } 492 - } 493 - } 494 - } 495 - } 496 - dict: (#struct){ 497 - r1: (#struct){ 498 - a: (#struct){ 499 - k: (string){ "simple" } 500 - d: (#struct){ 501 - n: (string){ "c1" } 502 - } 503 - } 504 - } 505 - } 506 - let subs#1 = (_){ _ } 507 - } 508 - } 428 + let subs#1multi = (〈3;#sub〉 & { 429 + #p: 〈2;rd〉.a 430 + }) 509 431 } 510 432 }
+8 -20
cue/testdata/eval/issue2235.txtar
··· 100 100 101 101 clusters: foo: {} 102 102 -- out/eval/stats -- 103 - Leaks: 1 104 - Freed: 99 105 - Reused: 80 103 + Leaks: 3 104 + Freed: 101 105 + Reused: 84 106 106 Allocs: 20 107 - Retain: 64 107 + Retain: 72 108 108 109 - Unifications: 100 110 - Conjuncts: 260 111 - Disjuncts: 151 109 + Unifications: 104 110 + Conjuncts: 271 111 + Disjuncts: 161 112 112 -- out/eval -- 113 113 (struct){ 114 114 shorewallParams: (#struct){ ··· 285 285 } 286 286 } 287 287 } 288 - let svc#1 = (struct){ 289 - spec: (struct){ 290 - externalIPs: (#list){ 291 - 0: (string){ "127.0.0.1" } 292 - } 293 - } 294 - metadata: (struct){ 295 - labels: (struct){ 296 - "ingress-class": (string){ "admin" } 297 - stack: (string){ "ingress" } 298 - } 299 - } 300 - } 288 + let svc#1multi = 〈1;controller〉.objects.namespaced.ingress.Service["\(〈1;class〉)-nginx-ingress-controller"] 301 289 } 302 290 -- out/compile -- 303 291 --- issue2235.cue
+21 -39
cue/testdata/eval/let.txtar
··· 159 159 } 160 160 161 161 -- out/eval/stats -- 162 - Leaks: 43 163 - Freed: 161 164 - Reused: 152 165 - Allocs: 52 166 - Retain: 202 162 + Leaks: 51 163 + Freed: 159 164 + Reused: 150 165 + Allocs: 60 166 + Retain: 188 167 167 168 - Unifications: 190 169 - Conjuncts: 377 170 - Disjuncts: 246 168 + Unifications: 196 169 + Conjuncts: 373 170 + Disjuncts: 248 171 171 -- out/eval -- 172 172 Errors: 173 173 indirectReference.y: conflicting values 2 and 1: ··· 253 253 1: (int){ 2 } 254 254 2: (int){ 3 } 255 255 } 256 - let Y#1A = (_|_){ 257 - // [eval] referencesForDirectly.Y: conflicting values 12 and 4: 258 - // ./incomprehension.cue:15:2 259 - // ./incomprehension.cue:16:11 260 - // referencesForDirectly.Y: conflicting values 8 and 4: 261 - // ./incomprehension.cue:15:2 262 - // ./incomprehension.cue:16:11 263 - } 256 + let Y#1Amulti = (〈1;v〉 * 4) 264 257 "0": (int){ 4 } 265 258 "1": (int){ 8 } 266 259 "2": (int){ 12 } ··· 271 264 1: (int){ 2 } 272 265 2: (int){ 3 } 273 266 } 274 - let Y#1B = (_|_){ 275 - // [eval] referencesForViaLet.Y: conflicting values 12 and 4: 276 - // ./incomprehension.cue:23:2 277 - // ./incomprehension.cue:23:24 278 - // ./incomprehension.cue:24:11 279 - // referencesForViaLet.Y: conflicting values 8 and 4: 280 - // ./incomprehension.cue:23:2 281 - // ./incomprehension.cue:23:24 282 - // ./incomprehension.cue:24:11 283 - } 267 + let Y#1Bmulti = 〈1;X〉 284 268 "0": (int){ 4 } 285 269 "1": (int){ 8 } 286 270 "2": (int){ 12 } ··· 366 350 } 367 351 } 368 352 nestedFor: (struct){ 369 - let X#1E = (struct){ 370 - let X#1Fmulti = 〈1;x〉 371 - "1": (int){ 1 } 372 - "2": (int){ 2 } 353 + let X#1Emulti = { 354 + for _, x in [ 355 + 1, 356 + 2, 357 + ] { 358 + let X#1Fmulti = 〈1;x〉 359 + "\(〈0;let X#1F〉)": 〈0;let X#1F〉 360 + } 373 361 } 374 362 "0": (struct){ 375 363 let X#1Fmulti = 〈1;x〉 ··· 416 404 a: (string){ "d" } 417 405 b: (string){ "e" } 418 406 } 419 - let T#23 = (_|_){ 420 - // [eval] letWithDynamicInComprehension.T: conflicting values "e" and "d": 421 - // ./issue2166.cue:3:6 422 - // ./issue2166.cue:4:6 423 - // ./issue2166.cue:7:2 424 - // ./issue2166.cue:8:11 425 - } 407 + let T#23multi = 〈1;v〉 426 408 d: (string){ "1" } 427 409 e: (string){ "1" } 428 410 } ··· 439 421 } 440 422 } 441 423 disabled_parent_test: (struct){ 442 - let parent_config#24 = (bool){ false } 424 + let parent_config#24multi = (*〈3;_parent_configs〉[〈1;v〉.parent]|false) 443 425 CHILD1: (struct){ 444 426 parent_config: (bool){ false } 445 427 } 446 428 CHILD2: (struct){ 447 - parent_config: (bool){ false } 429 + parent_config: (bool){ |(*(bool){ true }, (bool){ false }) } 448 430 } 449 431 } 450 432 }
+2 -1
internal/core/adt/comprehension.go
··· 203 203 } 204 204 205 205 conjunct := MakeConjunct(env, c, ci) 206 - n.node.state.insertFieldUnchecked(f.Label, ArcMember, conjunct) 206 + arc := n.node.state.insertFieldUnchecked(f.Label, ArcMember, conjunct) 207 + arc.MultiLet = f.IsMulti 207 208 208 209 fields = append(fields, f) 209 210