this repo has no description
0
fork

Configure Feed

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

cue: add a regression test for a disjunction bug fixed in evalv3

As can be seen in the diff, the old evaluator resulted in the fields:

h: a: v: *"a" | "b" | "c"
h: b: v: *"a" | "b" | "c"
h: c: v: *"a" | *"b" | *"c"

Which, when exporting, would understandably result in an error:

h.c.v: incomplete value "a" | "b" | "c"

The new evaluator correctly keeps "a" as the only default in all fields:

h: a: v: *"a" | "b" | "c"
h: b: v: *"a" | "b" | "c"
h: c: v: *"a" | "b" | "c"

Closes #770.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Id3e5e9c522307900331dc0fa29b936f773750497
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195003
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+121 -5
+121 -5
cue/testdata/disjunctions/elimination.txtar
··· 505 505 {name: "an exception"}, 506 506 ] 507 507 } 508 + -- issue770.cue -- 509 + issue770: { 510 + #A: { 511 + v: "a" | "b" | "c" 512 + } 513 + h: [string]: #A 514 + h: a: { 515 + v: *"a" | string 516 + } 517 + h: [=~"^b"]: { 518 + v: *h.a.v | string 519 + } 520 + h: [=~"^c"]: { 521 + v: *h.b.v | string 522 + } 523 + h: b: _ 524 + h: boo: _ 525 + h: c: _ 526 + h: coo: _ 527 + } 508 528 -- out/evalalpha -- 509 529 (struct){ 510 530 disambiguateClosed: (struct){ ··· 1441 1461 } 1442 1462 } 1443 1463 } 1464 + issue770: (struct){ 1465 + #A: (#struct){ 1466 + v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) } 1467 + } 1468 + h: (struct){ 1469 + a: (#struct){ 1470 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 1471 + } 1472 + b: (#struct){ 1473 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 1474 + } 1475 + boo: (#struct){ 1476 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 1477 + } 1478 + c: (#struct){ 1479 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 1480 + } 1481 + coo: (#struct){ 1482 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 1483 + } 1484 + } 1485 + } 1444 1486 } 1445 1487 -- diff/-out/evalalpha<==>+out/eval -- 1446 1488 diff old new ··· 2279 2321 } 2280 2322 } 2281 2323 } 2324 + @@ -1078,10 +948,10 @@ 2325 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 2326 + } 2327 + c: (#struct){ 2328 + - v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) } 2329 + + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 2330 + } 2331 + coo: (#struct){ 2332 + - v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) } 2333 + + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 2334 + } 2335 + } 2336 + } 2282 2337 -- out/eval/stats -- 2283 2338 Leaks: 4 2284 - Freed: 2403 2285 - Reused: 2387 2339 + Freed: 2554 2340 + Reused: 2538 2286 2341 Allocs: 20 2287 2342 Retain: 115 2288 2343 2289 - Unifications: 1278 2290 - Conjuncts: 3512 2291 - Disjuncts: 2518 2344 + Unifications: 1292 2345 + Conjuncts: 3726 2346 + Disjuncts: 2669 2292 2347 -- diff/todo/p1 -- 2293 2348 issue2263.full: missing elimination, may be lack of closeContext 2294 2349 -- diff/todo/p2 -- ··· 2302 2357 preserveClosedness.medium.p*: discarding of default is correct. 2303 2358 issue1417: new evaluator fixes known bug 2304 2359 issue3149: new evaluator fixes known bug 2360 + issue770: new evaluator fixes a bug in "c" and "coo" where defaults did not apply correctly. 2305 2361 -- out/eval -- 2306 2362 Errors: 2307 2363 issue1417.ids.2: 2 errors in empty disjunction: ··· 3368 3424 } 3369 3425 } 3370 3426 } 3427 + issue770: (struct){ 3428 + #A: (#struct){ 3429 + v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) } 3430 + } 3431 + h: (struct){ 3432 + a: (#struct){ 3433 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 3434 + } 3435 + b: (#struct){ 3436 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 3437 + } 3438 + boo: (#struct){ 3439 + v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 3440 + } 3441 + c: (#struct){ 3442 + v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) } 3443 + } 3444 + coo: (#struct){ 3445 + v: (string){ |(*(string){ "a" }, *(string){ "b" }, *(string){ "c" }) } 3446 + } 3447 + } 3448 + } 3371 3449 } 3372 3450 -- out/compile -- 3373 3451 --- in.cue ··· 4432 4510 ] 4433 4511 } 4434 4512 } 4513 + --- issue770.cue 4514 + { 4515 + issue770: { 4516 + #A: { 4517 + v: ("a"|"b"|"c") 4518 + } 4519 + h: { 4520 + [string]: 〈1;#A〉 4521 + } 4522 + h: { 4523 + a: { 4524 + v: (*"a"|string) 4525 + } 4526 + } 4527 + h: { 4528 + [=~"^b"]: { 4529 + v: (*〈2;h〉.a.v|string) 4530 + } 4531 + } 4532 + h: { 4533 + [=~"^c"]: { 4534 + v: (*〈2;h〉.b.v|string) 4535 + } 4536 + } 4537 + h: { 4538 + b: _ 4539 + } 4540 + h: { 4541 + boo: _ 4542 + } 4543 + h: { 4544 + c: _ 4545 + } 4546 + h: { 4547 + coo: _ 4548 + } 4549 + } 4550 + }