this repo has no description
0
fork

Configure Feed

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

internal/core/adt: fix disjunction state management

This fixes two problems:
- the disjunctionTasks was not decremented upon
completion of processing disjunctions. This meant
that related tasks were always yielded and "unblocked".
- in "attemptOnly" mode, when requesting disjunctions
to be solved, it would not finalize disjunctions,
causing, likewise, tasks to be yielded.

This also fixes a P2 error in previous tests.

Fixes #3925
Fixes #3905

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

+90 -225
+25 -66
cue/testdata/cycle/chain.txtar
··· 449 449 } 450 450 } 451 451 full: (struct){ 452 - #RecurseN: (_|_){ 453 - // [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _: 454 - // ./issue2052.cue:111:15 455 - // issue2052.full.#RecurseN: undefined field: "0": 456 - // ./issue2052.cue:121:10 452 + #RecurseN: (_){ 453 + _ 457 454 #maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) } 458 455 #funcFactory: (#struct){ 459 456 #next: (_){ _ } 460 457 #func: (_){ _ } 461 458 } 462 - #funcs: (_|_){ 463 - // [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _: 464 - // ./issue2052.cue:111:15 465 - // issue2052.full.#RecurseN.#funcs: invalid interpolation: non-concrete value _ (type _): 466 - // ./issue2052.cue:117:11 459 + #funcs: (#struct){ 460 + "4": (null){ null } 461 + "0": (_){ _ } 462 + "1": (_){ _ } 463 + "2": (_){ _ } 464 + "3": (_){ _ } 467 465 } 468 466 } 469 467 #DepthF: (#struct){ ··· 1127 1125 #basic: ((null|string)){ |((string){ string }, (null){ null }) } 1128 1126 out: (int){ 1 } 1129 1127 } 1130 - @@ -223,19 +215,21 @@ 1131 - } 1132 - } 1133 - full: (struct){ 1134 - - #RecurseN: (_){ 1135 - - _ 1136 - + #RecurseN: (_|_){ 1137 - + // [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _: 1138 - + // ./issue2052.cue:111:15 1139 - + // issue2052.full.#RecurseN: undefined field: "0": 1140 - + // ./issue2052.cue:121:10 1141 - #maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) } 1142 - #funcFactory: (#struct){ 1143 - #next: (_){ _ } 1144 - #func: (_){ _ } 1145 - } 1146 - - #funcs: (#struct){ 1147 - - "4": (null){ null } 1148 - - "0": (_){ _ } 1149 - - "1": (_){ _ } 1150 - - "2": (_){ _ } 1151 - - "3": (_){ _ } 1152 - + #funcs: (_|_){ 1153 - + // [incomplete] issue2052.full.#RecurseN: error in call to list.Range: non-concrete value _: 1154 - + // ./issue2052.cue:111:15 1155 - + // issue2052.full.#RecurseN.#funcs: invalid interpolation: non-concrete value _ (type _): 1156 - + // ./issue2052.cue:117:11 1157 - } 1158 - } 1159 - #DepthF: (#struct){ 1160 - @@ -245,7 +239,13 @@ 1128 + @@ -245,7 +237,13 @@ 1161 1129 #basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) } 1162 1130 out: (int){ 1163 1131 1 ··· 1172 1140 } 1173 1141 } 1174 1142 } 1175 - @@ -258,98 +258,170 @@ 1143 + @@ -258,98 +256,170 @@ 1176 1144 #basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) } 1177 1145 out: (int){ 1178 1146 1 ··· 1435 1403 } 1436 1404 } 1437 1405 } 1438 - @@ -357,7 +429,13 @@ 1406 + @@ -357,7 +427,13 @@ 1439 1407 #basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) } 1440 1408 out: (int){ 1441 1409 1 ··· 1450 1418 } 1451 1419 } 1452 1420 tree: (struct){ 1453 - @@ -371,49 +449,7 @@ 1421 + @@ -371,49 +447,7 @@ 1454 1422 } 1455 1423 cow: (string){ "moo" } 1456 1424 } ··· 1501 1469 #in: (#struct){ 1502 1470 a: (#struct){ 1503 1471 foo: (string){ "bar" } 1504 - @@ -425,6 +461,192 @@ 1472 + @@ -425,6 +459,192 @@ 1505 1473 } 1506 1474 cow: (string){ "moo" } 1507 1475 } ··· 1695 1663 } 1696 1664 } 1697 1665 -- out/evalalpha/stats -- 1698 - Leaks: 3130 1666 + Leaks: 3149 1699 1667 Freed: 0 1700 1668 Reused: 0 1701 - Allocs: 3130 1669 + Allocs: 3149 1702 1670 Retain: 0 1703 1671 1704 - Unifications: 931 1705 - Conjuncts: 4994 1672 + Unifications: 940 1673 + Conjuncts: 5024 1706 1674 Disjuncts: 1615 1707 1675 1708 - CloseIDElems: 20484 1709 - NumCloseIDs: 1535 1676 + CloseIDElems: 20500 1677 + NumCloseIDs: 1548 1710 1678 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 1711 1679 diff old new 1712 1680 --- old ··· 1721 1689 -Unifications: 759 1722 1690 -Conjuncts: 3139 1723 1691 -Disjuncts: 1942 1724 - +Leaks: 3130 1692 + +Leaks: 3149 1725 1693 +Freed: 0 1726 1694 +Reused: 0 1727 - +Allocs: 3130 1695 + +Allocs: 3149 1728 1696 +Retain: 0 1729 1697 + 1730 - +Unifications: 931 1731 - +Conjuncts: 4994 1698 + +Unifications: 940 1699 + +Conjuncts: 5024 1732 1700 +Disjuncts: 1615 1733 1701 + 1734 - +CloseIDElems: 20484 1735 - +NumCloseIDs: 1535 1702 + +CloseIDElems: 20500 1703 + +NumCloseIDs: 1548 1736 1704 -- out/eval/stats -- 1737 1705 Leaks: 56 1738 1706 Freed: 1788 ··· 1743 1711 Unifications: 759 1744 1712 Conjuncts: 3139 1745 1713 Disjuncts: 1942 1746 - -- diff/todo/p2 -- 1747 - issue2052.full.#Recurse: cycle error. This is not the worst, as a self-reference 1748 - cycle is an incomplete error and more or less equivalent to _, but the same 1749 - resolution as V2 would be preferential. This is P2, rather than P1, as the 1750 - result for V3 is already better than V2. 1751 - -- diff/explanation -- 1752 - issue2052.full.d.#funcs: v3 has 11 elements, whereas v2 has 4. 1753 - It seems to me that v3 is correct, 11 is explicitly set in #Depth, 1754 - which is used in d. 1755 1714 -- out/eval -- 1756 1715 (struct){ 1757 1716 chain: (struct){
+33 -40
cue/testdata/eval/issue3905.txtar
··· 53 53 -- out/evalalpha -- 54 54 (struct){ 55 55 issue3905: (struct){ 56 - reduced: (_|_){ 57 - // [incomplete] issue3905.reduced: key value of dynamic field must be concrete, found _|_(cycle error): 58 - // ./in.cue:5:12 56 + reduced: (#struct){ 59 57 #Schema: (#struct){ 60 58 params: (#struct){ 61 59 name: (string){ |(*(string){ "foo" }, (string){ string }) } ··· 64 62 foo: (string){ "bar" } 65 63 } 66 64 } 65 + foo: (string){ "bar" } 67 66 } 68 - full: (_|_){ 69 - // [incomplete] issue3905.full: key value of dynamic field must be concrete, found _|_(cycle error): 70 - // ./in.cue:17:20 67 + full: (#struct){ 71 68 #ReferenceGrantBuilder: (#struct){ 72 69 parameters: (#struct){ 73 70 namespace: (string){ string } ··· 100 97 } 101 98 } 102 99 } 100 + foo: (#struct){ 101 + metadata: (#struct){ 102 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 103 + namespace: (string){ "foo" } 104 + labels?: (#struct){ 105 + } 106 + annotations?: (#struct){ 107 + } 108 + } 109 + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 110 + kind: (string){ "ReferenceGrant" } 111 + } 103 112 } 104 113 } 105 114 } ··· 107 116 diff old new 108 117 --- old 109 118 +++ new 110 - @@ -1,6 +1,8 @@ 111 - (struct){ 112 - issue3905: (struct){ 113 - - reduced: (#struct){ 114 - + reduced: (_|_){ 115 - + // [incomplete] issue3905.reduced: key value of dynamic field must be concrete, found _|_(cycle error): 116 - + // ./in.cue:5:12 117 - #Schema: (#struct){ 118 - params: (#struct){ 119 - name: (string){ |(*(string){ "foo" }, (string){ string }) } 120 - @@ -9,9 +11,10 @@ 121 - foo: (string){ "bar" } 122 - } 119 + @@ -11,7 +11,7 @@ 123 120 } 124 - - foo: (string){ "bar" } 125 - - } 121 + foo: (string){ "bar" } 122 + } 126 123 - full: (struct){ 127 - + } 128 - + full: (_|_){ 129 - + // [incomplete] issue3905.full: key value of dynamic field must be concrete, found _|_(cycle error): 130 - + // ./in.cue:17:20 124 + + full: (#struct){ 131 125 #ReferenceGrantBuilder: (#struct){ 132 126 parameters: (#struct){ 133 127 namespace: (string){ string } 134 - @@ -19,8 +22,6 @@ 128 + @@ -19,8 +19,6 @@ 135 129 } 136 130 referenceGrant: (#struct){ 137 131 foo: (#struct){ ··· 140 134 metadata: (#struct){ 141 135 name: (string){ |(*(string){ "foo" }, (string){ string }) } 142 136 namespace: (string){ string } 143 - @@ -29,6 +30,8 @@ 137 + @@ -29,6 +27,8 @@ 144 138 annotations?: (#struct){ 145 139 } 146 140 } ··· 149 143 } 150 144 } 151 145 } 152 - @@ -44,18 +47,6 @@ 153 - } 146 + @@ -45,8 +45,6 @@ 154 147 } 155 148 } 156 - - foo: (#struct){ 149 + foo: (#struct){ 157 150 - apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 158 151 - kind: (string){ "ReferenceGrant" } 159 - - metadata: (#struct){ 160 - - name: (string){ |(*(string){ "foo" }, (string){ string }) } 161 - - namespace: (string){ "foo" } 162 - - labels?: (#struct){ 163 - - } 164 - - annotations?: (#struct){ 165 - - } 166 - - } 167 - - } 152 + metadata: (#struct){ 153 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 154 + namespace: (string){ "foo" } 155 + @@ -55,6 +53,8 @@ 156 + annotations?: (#struct){ 157 + } 158 + } 159 + + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 160 + + kind: (string){ "ReferenceGrant" } 161 + } 168 162 } 169 163 } 170 - } 171 164 -- out/eval -- 172 165 (struct){ 173 166 issue3905: (struct){
+28 -116
cue/testdata/eval/v0.7.txtar
··· 758 758 ./definition.cue:3:11 759 759 definition.t1.err.a.c: field not allowed: 760 760 ./definition.cue:9:5 761 - issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 762 - ./chained.cue:8:11 763 - issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 764 - ./chained.cue:17:19 765 761 766 762 Result: 767 763 (_|_){ ··· 781 777 } 782 778 } 783 779 } 784 - issue3925: (_|_){ 785 - // [eval] 786 - reduced: (_|_){ 787 - // [eval] 788 - out: (_|_){ 789 - // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 790 - // ./chained.cue:8:11 791 - } 792 - in: (_|_){ 793 - // [eval] 780 + issue3925: (struct){ 781 + reduced: (struct){ 782 + out: (string){ "c: str\n" } 783 + in: (struct){ 794 784 a: (string){ "actual" } 795 - b: (_|_){ 796 - // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 797 - // ./chained.cue:8:11 785 + b: (struct){ 786 + actual: (struct){ 787 + c: (string){ "str" } 788 + } 798 789 } 799 790 } 800 791 } 801 - full: (_|_){ 802 - // [eval] 803 - out: (_|_){ 804 - // [eval] 805 - input1: (_|_){ 806 - // [eval] 792 + full: (struct){ 793 + out: (struct){ 794 + input1: (struct){ 807 795 early: (string){ "early value" } 808 - lateYAML: (_|_){ 809 - // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 810 - // ./chained.cue:17:19 811 - } 796 + lateYAML: (string){ "one: one value\n" } 812 797 } 813 798 } 814 - _inputs: (_|_){ 815 - // [eval] 816 - input1: (_|_){ 817 - // [eval] 799 + _inputs: (struct){ 800 + input1: (struct){ 818 801 name: (string){ "actual" } 819 - config: (_|_){ 820 - // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 821 - // ./chained.cue:17:19 802 + config: (struct){ 803 + actual: (struct){ 804 + one: (string){ "one value" } 805 + } 822 806 } 823 807 } 824 808 } ··· 1237 1221 diff old new 1238 1222 --- old 1239 1223 +++ new 1240 - @@ -1,16 +1,12 @@ 1224 + @@ -1,16 +1,8 @@ 1241 1225 Errors: 1242 1226 definition.t0.err.d1.env.c: field not allowed: 1243 1227 - ./definition.cue:2:12 ··· 1251 1235 -mutual.t4.ok.p0.z: cannot add to field c 1252 1236 -mutual.t4.ok.p4.z: cannot add to field b 1253 1237 -mutual.t4.ok.p4.z: cannot add to field c 1254 - +issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 1255 - + ./chained.cue:8:11 1256 - +issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 1257 - + ./chained.cue:17:19 1258 1238 1259 1239 Result: 1260 1240 (_|_){ 1261 - @@ -19,12 +15,7 @@ 1241 + @@ -19,12 +11,7 @@ 1262 1242 t1: (struct){ 1263 1243 ok: (struct){ 1264 1244 s3: (string){ strings.ContainsAny("dd") } ··· 1272 1252 } 1273 1253 } 1274 1254 t2: (struct){ 1275 - @@ -35,32 +26,44 @@ 1276 - } 1277 - } 1278 - } 1279 - - issue3925: (struct){ 1280 - - reduced: (struct){ 1281 - - out: (string){ "c: str\n" } 1282 - - in: (struct){ 1283 - + issue3925: (_|_){ 1284 - + // [eval] 1285 - + reduced: (_|_){ 1286 - + // [eval] 1287 - + out: (_|_){ 1288 - + // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 1289 - + // ./chained.cue:8:11 1290 - + } 1291 - + in: (_|_){ 1292 - + // [eval] 1293 - a: (string){ "actual" } 1294 - - b: (struct){ 1295 - - actual: (struct){ 1296 - - c: (string){ "str" } 1297 - - } 1298 - - } 1299 - - } 1300 - - } 1301 - - full: (struct){ 1302 - - out: (struct){ 1303 - - input1: (struct){ 1304 - + b: (_|_){ 1305 - + // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 1306 - + // ./chained.cue:8:11 1307 - + } 1308 - + } 1309 - + } 1310 - + full: (_|_){ 1311 - + // [eval] 1312 - + out: (_|_){ 1313 - + // [eval] 1314 - + input1: (_|_){ 1315 - + // [eval] 1316 - early: (string){ "early value" } 1317 - - lateYAML: (string){ "one: one value\n" } 1318 - - } 1319 - - } 1320 - - _inputs: (struct){ 1321 - - input1: (struct){ 1322 - + lateYAML: (_|_){ 1323 - + // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 1324 - + // ./chained.cue:17:19 1325 - + } 1326 - + } 1327 - + } 1328 - + _inputs: (_|_){ 1329 - + // [eval] 1330 - + input1: (_|_){ 1331 - + // [eval] 1332 - name: (string){ "actual" } 1333 - - config: (struct){ 1334 - - actual: (struct){ 1335 - - one: (string){ "one value" } 1336 - - } 1337 - + config: (_|_){ 1338 - + // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 1339 - + // ./chained.cue:17:19 1340 - } 1341 - } 1342 - } 1343 - @@ -92,9 +95,7 @@ 1255 + @@ -92,9 +79,7 @@ 1344 1256 // [eval] 1345 1257 c: (_|_){ 1346 1258 // [eval] definition.t0.err.d1.env.c: field not allowed: ··· 1350 1262 } 1351 1263 } 1352 1264 } 1353 - @@ -108,9 +109,7 @@ 1265 + @@ -108,9 +93,7 @@ 1354 1266 // [eval] 1355 1267 c: (_|_){ 1356 1268 // [eval] definition.t1.err.a.c: field not allowed: ··· 1360 1272 } 1361 1273 } 1362 1274 #A: (#struct){ 1363 - @@ -124,32 +123,32 @@ 1275 + @@ -124,32 +107,32 @@ 1364 1276 a: (int){ int } 1365 1277 } 1366 1278 x: (#struct){ ··· 1419 1331 } 1420 1332 #A: (#struct){ 1421 1333 a: (int){ int } 1422 - @@ -172,14 +171,7 @@ 1334 + @@ -172,14 +155,7 @@ 1423 1335 } 1424 1336 t2: (struct){ 1425 1337 ok: (struct){ ··· 1435 1347 #X: (#struct){ 1436 1348 a: (#struct){ 1437 1349 b: (#struct){ 1438 - @@ -233,8 +225,7 @@ 1350 + @@ -233,8 +209,7 @@ 1439 1351 } 1440 1352 } 1441 1353 } ··· 1445 1357 t0: (struct){ 1446 1358 ok: (struct){ 1447 1359 c: (struct){ 1448 - @@ -301,135 +292,116 @@ 1360 + @@ -301,135 +276,116 @@ 1449 1361 } 1450 1362 } 1451 1363 } ··· 1691 1603 } 1692 1604 } 1693 1605 p5: (struct){ 1694 - @@ -438,23 +410,20 @@ 1606 + @@ -438,23 +394,20 @@ 1695 1607 d: (struct){ 1696 1608 b: (int){ 2 } 1697 1609 } ··· 1729 1641 } 1730 1642 } 1731 1643 check: (struct){ 1732 - @@ -476,10 +445,7 @@ 1644 + @@ -476,10 +429,7 @@ 1733 1645 b: (int){ 2 } 1734 1646 } 1735 1647 y: (struct){
+2 -1
internal/core/adt/states.go
··· 191 191 // TODO: not adding this improves error message for issue3691 in 192 192 // eval/comprehensions.txtar. But without this, TestVisit of dep 193 193 // panics. Investigate. 194 - pendingKnown 194 + pendingKnown | 195 + disjunctionTask 195 196 196 197 // The xConjunct condition sets indicate a conjunct MAY contribute the to 197 198 // final result. For some conjuncts it may not be known what the
+2 -2
internal/core/adt/unify.go
··· 340 340 n.setBaseValue(err) 341 341 } 342 342 343 + n.finalizeDisjunctions() 344 + 343 345 if mode == attemptOnly { 344 346 return n.meets(needs) 345 347 } ··· 348 350 // TODO: phase3: validation 349 351 n.signal(mask) 350 352 } 351 - 352 - n.finalizeDisjunctions() 353 353 354 354 w = v.DerefValue() // Dereference anything, including shared nodes. 355 355 if w != v {