this repo has no description
0
fork

Configure Feed

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

internal/core/adt: add tests for issue 3784

Issue #3784

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

+509 -37
+509 -37
cue/testdata/disjunctions/elimination.txtar
··· 559 559 {v: 1} | 2 560 560 {v: 1} | 2 561 561 } 562 + -- issue3784.cue -- 563 + issue3784: reduced: { 564 + #Schema: a: { 565 + kind: "A" 566 + b: c?: string 567 + b: {} 568 + } | { 569 + kind: "B" 570 + } 571 + 572 + out: #Schema 573 + out: a: { 574 + kind: "A" 575 + b: c: "x" 576 + } 577 + } 578 + issue3784: full: { 579 + #Schema: { 580 + pages?: { 581 + build_type?: "legacy" | "workflow" 582 + source?: { 583 + branch?: string 584 + path?: string 585 + } 586 + cname?: string 587 + } 588 + pages?: { 589 + build_type!: "legacy" 590 + source!: { 591 + branch!: _ 592 + } 593 + } | close({ 594 + build_type!: "workflow" 595 + cname?: _ 596 + }) 597 + } 598 + out: #Schema & { 599 + pages: { 600 + cname: "foo.com" 601 + build_type: "legacy" 602 + source: { 603 + branch: "main" 604 + path: "/" 605 + } 606 + } 607 + } 608 + } 609 + issue3784: variant1: { 610 + #Schema: { 611 + pages: { 612 + build_type?: "legacy" | "workflow" 613 + source: { 614 + branch?: string 615 + path?: string 616 + } 617 + cname?: string 618 + } 619 + pages?: { 620 + build_type!: "legacy" 621 + source!: { 622 + branch!: _ 623 + } 624 + } | close({ 625 + build_type!: "workflow" 626 + cname?: _ 627 + }) 628 + } 629 + } 630 + issue3784: variant2: { 631 + #Schema: { 632 + build_type!: "legacy" 633 + source!: { 634 + branch!: _ 635 + } 636 + } | close({ 637 + build_type!: "workflow" 638 + cname?: _ 639 + }) 640 + a: #Schema 641 + a: { 642 + build_type?: "legacy" | "workflow" 643 + source: { 644 + branch?: string 645 + path?: string 646 + } 647 + cname?: string 648 + } 649 + } 562 650 -- out/evalalpha -- 563 - (struct){ 651 + Errors: 652 + issue3784.full.out.pages: 2 errors in empty disjunction: 653 + issue3784.full.out.pages.build_type: conflicting values "workflow" and "legacy": 654 + ./issue3784.cue:32:17 655 + ./issue3784.cue:39:16 656 + issue3784.full.out.pages.source.path: field not allowed: 657 + ./issue3784.cue:22:5 658 + ./issue3784.cue:42:5 659 + issue3784.reduced.out.a: 2 errors in empty disjunction: 660 + issue3784.reduced.out.a.b.c: field not allowed: 661 + ./issue3784.cue:4:6 662 + ./issue3784.cue:13:6 663 + issue3784.reduced.out.a.kind: conflicting values "B" and "A": 664 + ./issue3784.cue:7:9 665 + ./issue3784.cue:12:9 666 + 667 + Result: 668 + (_|_){ 669 + // [eval] 564 670 disambiguateClosed: (struct){ 565 671 b: (#struct){ |((#struct){ 566 672 x: (bool){ true } ··· 1511 1617 }, (int){ 2 }) } 1512 1618 } 1513 1619 } 1620 + issue3784: (_|_){ 1621 + // [eval] 1622 + reduced: (_|_){ 1623 + // [eval] 1624 + #Schema: (#struct){ 1625 + a: (#struct){ |((#struct){ 1626 + kind: (string){ "A" } 1627 + b: (#struct){ 1628 + c?: (string){ string } 1629 + } 1630 + }, (#struct){ 1631 + kind: (string){ "B" } 1632 + }) } 1633 + } 1634 + out: (_|_){ 1635 + // [eval] 1636 + a: (_|_){ 1637 + // [eval] issue3784.reduced.out.a: 2 errors in empty disjunction: 1638 + // issue3784.reduced.out.a.b.c: field not allowed: 1639 + // ./issue3784.cue:4:6 1640 + // ./issue3784.cue:13:6 1641 + // issue3784.reduced.out.a.kind: conflicting values "B" and "A": 1642 + // ./issue3784.cue:7:9 1643 + // ./issue3784.cue:12:9 1644 + kind: (string){ "A" } 1645 + b: (struct){ 1646 + c: (string){ "x" } 1647 + } 1648 + } 1649 + } 1650 + } 1651 + full: (_|_){ 1652 + // [eval] 1653 + #Schema: (#struct){ 1654 + pages?: (#struct){ |((#struct){ 1655 + build_type!: (string){ "legacy" } 1656 + source!: (#struct){ 1657 + branch!: (string){ string } 1658 + path?: (string){ string } 1659 + } 1660 + cname?: (string){ string } 1661 + }, (#struct){ 1662 + build_type!: (string){ "workflow" } 1663 + source?: (#struct){ 1664 + branch?: (string){ string } 1665 + path?: (string){ string } 1666 + } 1667 + cname?: (string){ string } 1668 + }) } 1669 + } 1670 + out: (_|_){ 1671 + // [eval] 1672 + pages: (_|_){ 1673 + // [eval] issue3784.full.out.pages: 2 errors in empty disjunction: 1674 + // issue3784.full.out.pages.build_type: conflicting values "workflow" and "legacy": 1675 + // ./issue3784.cue:32:17 1676 + // ./issue3784.cue:39:16 1677 + // issue3784.full.out.pages.source.path: field not allowed: 1678 + // ./issue3784.cue:22:5 1679 + // ./issue3784.cue:42:5 1680 + cname: (string){ "foo.com" } 1681 + build_type: (string){ "legacy" } 1682 + source: (#struct){ 1683 + branch: (string){ "main" } 1684 + path: (string){ "/" } 1685 + } 1686 + } 1687 + } 1688 + } 1689 + variant1: (struct){ 1690 + #Schema: (#struct){ 1691 + pages: (#struct){ 1692 + build_type!: (string){ "legacy" } 1693 + source: (#struct){ 1694 + branch!: (string){ string } 1695 + path?: (string){ string } 1696 + } 1697 + cname?: (string){ string } 1698 + } 1699 + } 1700 + } 1701 + variant2: (struct){ 1702 + #Schema: (#struct){ |((#struct){ 1703 + build_type!: (string){ "legacy" } 1704 + source!: (#struct){ 1705 + branch!: (_){ _ } 1706 + } 1707 + }, (#struct){ 1708 + build_type!: (string){ "workflow" } 1709 + cname?: (_){ _ } 1710 + }) } 1711 + a: (#struct){ 1712 + build_type!: (string){ "legacy" } 1713 + source: (#struct){ 1714 + branch!: (string){ string } 1715 + path?: (string){ string } 1716 + } 1717 + cname?: (string){ string } 1718 + } 1719 + } 1720 + } 1514 1721 issue770: (struct){ 1515 1722 #A: (#struct){ 1516 1723 v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) } ··· 1538 1745 diff old new 1539 1746 --- old 1540 1747 +++ new 1541 - @@ -1,58 +1,4 @@ 1542 - -Errors: 1748 + @@ -1,54 +1,18 @@ 1749 + Errors: 1543 1750 -issue1417.ids.2: 2 errors in empty disjunction: 1544 1751 -issue2209.full.Bar.resource.spec: 6 errors in empty disjunction: 1545 1752 -issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction: ··· 1590 1797 - ./issue3149.cue:3:46 1591 1798 - ./issue3149.cue:3:10 1592 1799 - ./issue3149.cue:10:10 1593 - - 1594 - -Result: 1595 - -(_|_){ 1596 - - // [eval] 1597 - +(struct){ 1598 - disambiguateClosed: (struct){ 1599 - b: (#struct){ |((#struct){ 1600 - x: (bool){ true } 1601 - @@ -181,7 +127,7 @@ 1800 + +issue3784.full.out.pages: 2 errors in empty disjunction: 1801 + +issue3784.full.out.pages.build_type: conflicting values "workflow" and "legacy": 1802 + + ./issue3784.cue:32:17 1803 + + ./issue3784.cue:39:16 1804 + +issue3784.full.out.pages.source.path: field not allowed: 1805 + + ./issue3784.cue:22:5 1806 + + ./issue3784.cue:42:5 1807 + +issue3784.reduced.out.a: 2 errors in empty disjunction: 1808 + +issue3784.reduced.out.a.b.c: field not allowed: 1809 + + ./issue3784.cue:4:6 1810 + + ./issue3784.cue:13:6 1811 + +issue3784.reduced.out.a.kind: conflicting values "B" and "A": 1812 + + ./issue3784.cue:7:9 1813 + + ./issue3784.cue:12:9 1814 + 1815 + Result: 1816 + (_|_){ 1817 + @@ -181,7 +145,7 @@ 1602 1818 x: ((null|struct)){ |((struct){ 1603 1819 a: (struct){ 1604 1820 b: (_|_){ ··· 1607 1823 // ./in.cue:138:15 1608 1824 // ./in.cue:124:15 1609 1825 // ./in.cue:125:12 1610 - @@ -205,24 +151,24 @@ 1826 + @@ -205,24 +169,24 @@ 1611 1827 preserveClosedness: (struct){ 1612 1828 small: (struct){ 1613 1829 p1: (struct){ ··· 1650 1866 a: (string){ string } 1651 1867 }, (#struct){ 1652 1868 a: (string){ string } 1653 - @@ -241,40 +187,40 @@ 1869 + @@ -241,40 +205,40 @@ 1654 1870 } 1655 1871 medium: (struct){ 1656 1872 p1: (struct){ ··· 1725 1941 a: (string){ string } 1726 1942 }, (#struct){ 1727 1943 a: (string){ string } 1728 - @@ -307,7 +253,7 @@ 1944 + @@ -307,7 +271,7 @@ 1729 1945 }) } 1730 1946 } 1731 1947 p3: (struct){ ··· 1734 1950 a: (string){ string } 1735 1951 }, (#struct){ 1736 1952 a: (string){ string } 1737 - @@ -349,10 +295,6 @@ 1953 + @@ -349,10 +313,6 @@ 1738 1954 #type: (#struct){ 1739 1955 fieldName: ((string|struct)){ |((string){ string }, (#struct){ 1740 1956 foo: (string){ string } ··· 1745 1961 }) } 1746 1962 } 1747 1963 #subtype: ((string|struct)){ |((string){ string }, (#struct){ 1748 - @@ -432,12 +374,8 @@ 1964 + @@ -432,12 +392,8 @@ 1749 1965 #T: (list){ 1750 1966 0: (string){ "d" } 1751 1967 } ··· 1760 1976 } 1761 1977 issue1940: (struct){ 1762 1978 #T: (#list){ 1763 - @@ -446,53 +384,24 @@ 1979 + @@ -446,53 +402,24 @@ 1764 1980 } 1765 1981 } 1766 1982 #A: (#struct){ ··· 1826 2042 t1: (struct){ 1827 2043 #SpecFoo: (#struct){ 1828 2044 foo: (#struct){ 1829 - @@ -510,36 +419,20 @@ 2045 + @@ -510,36 +437,20 @@ 1830 2046 } 1831 2047 } 1832 2048 out: (struct){ |((struct){ ··· 1877 2093 nullBar: (null){ null } 1878 2094 }) } 1879 2095 } 1880 - @@ -555,48 +448,74 @@ 2096 + @@ -555,48 +466,74 @@ 1881 2097 x: (int){ 1 } 1882 2098 } 1883 2099 } ··· 1994 2210 Foo: (#struct){ 1995 2211 spec: (#struct){ 1996 2212 foo: (#struct){ 1997 - @@ -605,135 +524,52 @@ 2213 + @@ -605,135 +542,52 @@ 1998 2214 } 1999 2215 } 2000 2216 resource: (#struct){ ··· 2176 2392 } 2177 2393 } 2178 2394 #Abstract: (#struct){ 2179 - @@ -749,34 +585,34 @@ 2395 + @@ -749,34 +603,34 @@ 2180 2396 } 2181 2397 }) } 2182 2398 resource: (#struct){ ··· 2239 2455 } 2240 2456 } 2241 2457 _#Spec: (#struct){ |(*(#struct){ 2242 - @@ -803,36 +639,36 @@ 2458 + @@ -803,36 +657,36 @@ 2243 2459 } 2244 2460 } 2245 2461 _Thing: (#struct){ ··· 2305 2521 } 2306 2522 #Constrained: (#struct){ 2307 2523 spec: (#struct){ |(*(#struct){ 2308 - @@ -916,19 +752,19 @@ 2524 + @@ -916,19 +770,19 @@ 2309 2525 common: (int){ 3 } 2310 2526 } 2311 2527 #FormFoo: (#struct){ ··· 2332 2548 }) } 2333 2549 } 2334 2550 #Input: (#struct){ 2335 - @@ -936,18 +772,12 @@ 2551 + @@ -936,18 +790,12 @@ 2336 2552 } 2337 2553 } 2338 2554 #summarizeReturn: (#struct){ ··· 2353 2569 out: (#list){ 2354 2570 } 2355 2571 } 2356 - @@ -977,10 +807,23 @@ 2572 + @@ -977,10 +825,23 @@ 2357 2573 } 2358 2574 full: (struct){ 2359 2575 metrics: (#list){ ··· 2381 2597 1: (#struct){ 2382 2598 id: (string){ "bar" } 2383 2599 value: (int){ 80 } 2384 - @@ -1031,13 +874,11 @@ 2600 + @@ -1031,13 +892,11 @@ 2385 2601 } 2386 2602 } 2387 2603 } ··· 2397 2613 0: (#struct){ 2398 2614 name: (string){ "FooBarFoo" } 2399 2615 } 2400 - @@ -1047,19 +888,8 @@ 2616 + @@ -1047,19 +906,8 @@ 2401 2617 2: (#struct){ 2402 2618 name: (string){ "FooQuuxFoo" } 2403 2619 } ··· 2419 2635 } 2420 2636 } 2421 2637 } 2422 - @@ -1134,10 +964,10 @@ 2638 + @@ -1119,8 +967,10 @@ 2639 + }, (int){ 2 }) } 2640 + } 2641 + } 2642 + - issue3784: (struct){ 2643 + - reduced: (struct){ 2644 + + issue3784: (_|_){ 2645 + + // [eval] 2646 + + reduced: (_|_){ 2647 + + // [eval] 2648 + #Schema: (#struct){ 2649 + a: (#struct){ |((#struct){ 2650 + kind: (string){ "A" } 2651 + @@ -1131,16 +981,25 @@ 2652 + kind: (string){ "B" } 2653 + }) } 2654 + } 2655 + - out: (#struct){ 2656 + - a: (#struct){ 2657 + + out: (_|_){ 2658 + + // [eval] 2659 + + a: (_|_){ 2660 + + // [eval] issue3784.reduced.out.a: 2 errors in empty disjunction: 2661 + + // issue3784.reduced.out.a.b.c: field not allowed: 2662 + + // ./issue3784.cue:4:6 2663 + + // ./issue3784.cue:13:6 2664 + + // issue3784.reduced.out.a.kind: conflicting values "B" and "A": 2665 + + // ./issue3784.cue:7:9 2666 + + // ./issue3784.cue:12:9 2667 + kind: (string){ "A" } 2668 + - b: (#struct){ 2669 + + b: (struct){ 2670 + c: (string){ "x" } 2671 + } 2672 + } 2673 + } 2674 + } 2675 + - full: (struct){ 2676 + + full: (_|_){ 2677 + + // [eval] 2678 + #Schema: (#struct){ 2679 + pages?: (#struct){ |((#struct){ 2680 + build_type!: (string){ "legacy" } 2681 + @@ -1158,14 +1017,22 @@ 2682 + cname?: (string){ string } 2683 + }) } 2684 + } 2685 + - out: (#struct){ 2686 + - pages: (#struct){ 2687 + + out: (_|_){ 2688 + + // [eval] 2689 + + pages: (_|_){ 2690 + + // [eval] issue3784.full.out.pages: 2 errors in empty disjunction: 2691 + + // issue3784.full.out.pages.build_type: conflicting values "workflow" and "legacy": 2692 + + // ./issue3784.cue:32:17 2693 + + // ./issue3784.cue:39:16 2694 + + // issue3784.full.out.pages.source.path: field not allowed: 2695 + + // ./issue3784.cue:22:5 2696 + + // ./issue3784.cue:42:5 2697 + + cname: (string){ "foo.com" } 2698 + build_type: (string){ "legacy" } 2699 + source: (#struct){ 2700 + branch: (string){ "main" } 2701 + path: (string){ "/" } 2702 + } 2703 + - cname: (string){ "foo.com" } 2704 + } 2705 + } 2706 + } 2707 + @@ -1216,10 +1083,10 @@ 2423 2708 v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 2424 2709 } 2425 2710 c: (#struct){ ··· 2433 2718 } 2434 2719 } 2435 2720 -- out/eval/stats -- 2436 - Leaks: 4 2437 - Freed: 2684 2438 - Reused: 2668 2439 - Allocs: 20 2440 - Retain: 118 2721 + Leaks: 9 2722 + Freed: 2786 2723 + Reused: 2771 2724 + Allocs: 24 2725 + Retain: 123 2441 2726 2442 - Unifications: 1350 2443 - Conjuncts: 3905 2444 - Disjuncts: 2802 2727 + Unifications: 1427 2728 + Conjuncts: 4068 2729 + Disjuncts: 2909 2445 2730 -- diff/todo/p1 -- 2446 2731 issue2263.full: missing elimination, may be lack of closeContext 2447 2732 issue2209.simplified.t3: ditto ··· 3578 3863 }, (int){ 2 }) } 3579 3864 } 3580 3865 } 3866 + issue3784: (struct){ 3867 + reduced: (struct){ 3868 + #Schema: (#struct){ 3869 + a: (#struct){ |((#struct){ 3870 + kind: (string){ "A" } 3871 + b: (#struct){ 3872 + c?: (string){ string } 3873 + } 3874 + }, (#struct){ 3875 + kind: (string){ "B" } 3876 + }) } 3877 + } 3878 + out: (#struct){ 3879 + a: (#struct){ 3880 + kind: (string){ "A" } 3881 + b: (#struct){ 3882 + c: (string){ "x" } 3883 + } 3884 + } 3885 + } 3886 + } 3887 + full: (struct){ 3888 + #Schema: (#struct){ 3889 + pages?: (#struct){ |((#struct){ 3890 + build_type!: (string){ "legacy" } 3891 + source!: (#struct){ 3892 + branch!: (string){ string } 3893 + path?: (string){ string } 3894 + } 3895 + cname?: (string){ string } 3896 + }, (#struct){ 3897 + build_type!: (string){ "workflow" } 3898 + source?: (#struct){ 3899 + branch?: (string){ string } 3900 + path?: (string){ string } 3901 + } 3902 + cname?: (string){ string } 3903 + }) } 3904 + } 3905 + out: (#struct){ 3906 + pages: (#struct){ 3907 + build_type: (string){ "legacy" } 3908 + source: (#struct){ 3909 + branch: (string){ "main" } 3910 + path: (string){ "/" } 3911 + } 3912 + cname: (string){ "foo.com" } 3913 + } 3914 + } 3915 + } 3916 + variant1: (struct){ 3917 + #Schema: (#struct){ 3918 + pages: (#struct){ 3919 + build_type!: (string){ "legacy" } 3920 + source: (#struct){ 3921 + branch!: (string){ string } 3922 + path?: (string){ string } 3923 + } 3924 + cname?: (string){ string } 3925 + } 3926 + } 3927 + } 3928 + variant2: (struct){ 3929 + #Schema: (#struct){ |((#struct){ 3930 + build_type!: (string){ "legacy" } 3931 + source!: (#struct){ 3932 + branch!: (_){ _ } 3933 + } 3934 + }, (#struct){ 3935 + build_type!: (string){ "workflow" } 3936 + cname?: (_){ _ } 3937 + }) } 3938 + a: (#struct){ 3939 + build_type!: (string){ "legacy" } 3940 + source: (#struct){ 3941 + branch!: (string){ string } 3942 + path?: (string){ string } 3943 + } 3944 + cname?: (string){ string } 3945 + } 3946 + } 3947 + } 3581 3948 issue770: (struct){ 3582 3949 #A: (#struct){ 3583 3950 v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) } ··· 4737 5104 ({ 4738 5105 v: 1 4739 5106 }|2) 5107 + } 5108 + } 5109 + } 5110 + } 5111 + --- issue3784.cue 5112 + { 5113 + issue3784: { 5114 + reduced: { 5115 + #Schema: { 5116 + a: ({ 5117 + kind: "A" 5118 + b: { 5119 + c?: string 5120 + } 5121 + b: {} 5122 + }|{ 5123 + kind: "B" 5124 + }) 5125 + } 5126 + out: 〈0;#Schema〉 5127 + out: { 5128 + a: { 5129 + kind: "A" 5130 + b: { 5131 + c: "x" 5132 + } 5133 + } 5134 + } 5135 + } 5136 + } 5137 + issue3784: { 5138 + full: { 5139 + #Schema: { 5140 + pages?: { 5141 + build_type?: ("legacy"|"workflow") 5142 + source?: { 5143 + branch?: string 5144 + path?: string 5145 + } 5146 + cname?: string 5147 + } 5148 + pages?: ({ 5149 + build_type!: "legacy" 5150 + source!: { 5151 + branch!: _ 5152 + } 5153 + }|close({ 5154 + build_type!: "workflow" 5155 + cname?: _ 5156 + })) 5157 + } 5158 + out: (〈0;#Schema〉 & { 5159 + pages: { 5160 + cname: "foo.com" 5161 + build_type: "legacy" 5162 + source: { 5163 + branch: "main" 5164 + path: "/" 5165 + } 5166 + } 5167 + }) 5168 + } 5169 + } 5170 + issue3784: { 5171 + variant1: { 5172 + #Schema: { 5173 + pages: { 5174 + build_type?: ("legacy"|"workflow") 5175 + source: { 5176 + branch?: string 5177 + path?: string 5178 + } 5179 + cname?: string 5180 + } 5181 + pages?: ({ 5182 + build_type!: "legacy" 5183 + source!: { 5184 + branch!: _ 5185 + } 5186 + }|close({ 5187 + build_type!: "workflow" 5188 + cname?: _ 5189 + })) 5190 + } 5191 + } 5192 + } 5193 + issue3784: { 5194 + variant2: { 5195 + #Schema: ({ 5196 + build_type!: "legacy" 5197 + source!: { 5198 + branch!: _ 5199 + } 5200 + }|close({ 5201 + build_type!: "workflow" 5202 + cname?: _ 5203 + })) 5204 + a: 〈0;#Schema〉 5205 + a: { 5206 + build_type?: ("legacy"|"workflow") 5207 + source: { 5208 + branch?: string 5209 + path?: string 5210 + } 5211 + cname?: string 4740 5212 } 4741 5213 } 4742 5214 }