Skip to content

Commit e145a14

Browse files
committed
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 <[email protected]> Change-Id: I79b70f0673a8283dcb4afb274c1b9e4c5c38892d Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1215093 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 38357b7 commit e145a14

File tree

5 files changed

+90
-225
lines changed

5 files changed

+90
-225
lines changed

cue/testdata/cycle/chain.txtar

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -449,21 +449,19 @@ issue2052: full: {
449449
}
450450
}
451451
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+
_
457454
#maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) }
458455
#funcFactory: (#struct){
459456
#next: (_){ _ }
460457
#func: (_){ _ }
461458
}
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": (_){ _ }
467465
}
468466
}
469467
#DepthF: (#struct){
@@ -1127,37 +1125,7 @@ diff old new
11271125
#basic: ((null|string)){ |((string){ string }, (null){ null }) }
11281126
out: (int){ 1 }
11291127
}
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 @@
11611129
#basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) }
11621130
out: (int){
11631131
1
@@ -1172,7 +1140,7 @@ diff old new
11721140
}
11731141
}
11741142
}
1175-
@@ -258,98 +258,170 @@
1143+
@@ -258,98 +256,170 @@
11761144
#basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) }
11771145
out: (int){
11781146
1
@@ -1435,7 +1403,7 @@ diff old new
14351403
}
14361404
}
14371405
}
1438-
@@ -357,7 +429,13 @@
1406+
@@ -357,7 +427,13 @@
14391407
#basic: ((null|string|bytes|number)){ |((int){ int }, (number){ number }, (string){ string }, (bytes){ bytes }, (null){ null }) }
14401408
out: (int){
14411409
1
@@ -1450,7 +1418,7 @@ diff old new
14501418
}
14511419
}
14521420
tree: (struct){
1453-
@@ -371,49 +449,7 @@
1421+
@@ -371,49 +447,7 @@
14541422
}
14551423
cow: (string){ "moo" }
14561424
}
@@ -1501,7 +1469,7 @@ diff old new
15011469
#in: (#struct){
15021470
a: (#struct){
15031471
foo: (string){ "bar" }
1504-
@@ -425,6 +461,192 @@
1472+
@@ -425,6 +459,192 @@
15051473
}
15061474
cow: (string){ "moo" }
15071475
}
@@ -1695,18 +1663,18 @@ diff old new
16951663
}
16961664
}
16971665
-- out/evalalpha/stats --
1698-
Leaks: 3130
1666+
Leaks: 3149
16991667
Freed: 0
17001668
Reused: 0
1701-
Allocs: 3130
1669+
Allocs: 3149
17021670
Retain: 0
17031671

1704-
Unifications: 931
1705-
Conjuncts: 4994
1672+
Unifications: 940
1673+
Conjuncts: 5024
17061674
Disjuncts: 1615
17071675

1708-
CloseIDElems: 20484
1709-
NumCloseIDs: 1535
1676+
CloseIDElems: 20500
1677+
NumCloseIDs: 1548
17101678
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
17111679
diff old new
17121680
--- old
@@ -1721,18 +1689,18 @@ diff old new
17211689
-Unifications: 759
17221690
-Conjuncts: 3139
17231691
-Disjuncts: 1942
1724-
+Leaks: 3130
1692+
+Leaks: 3149
17251693
+Freed: 0
17261694
+Reused: 0
1727-
+Allocs: 3130
1695+
+Allocs: 3149
17281696
+Retain: 0
17291697
+
1730-
+Unifications: 931
1731-
+Conjuncts: 4994
1698+
+Unifications: 940
1699+
+Conjuncts: 5024
17321700
+Disjuncts: 1615
17331701
+
1734-
+CloseIDElems: 20484
1735-
+NumCloseIDs: 1535
1702+
+CloseIDElems: 20500
1703+
+NumCloseIDs: 1548
17361704
-- out/eval/stats --
17371705
Leaks: 56
17381706
Freed: 1788
@@ -1743,15 +1711,6 @@ Retain: 174
17431711
Unifications: 759
17441712
Conjuncts: 3139
17451713
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.
17551714
-- out/eval --
17561715
(struct){
17571716
chain: (struct){

cue/testdata/eval/issue3905.txtar

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ Disjuncts: 81
5353
-- out/evalalpha --
5454
(struct){
5555
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){
5957
#Schema: (#struct){
6058
params: (#struct){
6159
name: (string){ |(*(string){ "foo" }, (string){ string }) }
@@ -64,10 +62,9 @@ Disjuncts: 81
6462
foo: (string){ "bar" }
6563
}
6664
}
65+
foo: (string){ "bar" }
6766
}
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){
7168
#ReferenceGrantBuilder: (#struct){
7269
parameters: (#struct){
7370
namespace: (string){ string }
@@ -100,38 +97,35 @@ Disjuncts: 81
10097
}
10198
}
10299
}
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+
}
103112
}
104113
}
105114
}
106115
-- diff/-out/evalalpha<==>+out/eval --
107116
diff old new
108117
--- old
109118
+++ 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 @@
123120
}
124-
- foo: (string){ "bar" }
125-
- }
121+
foo: (string){ "bar" }
122+
}
126123
- 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){
131125
#ReferenceGrantBuilder: (#struct){
132126
parameters: (#struct){
133127
namespace: (string){ string }
134-
@@ -19,8 +22,6 @@
128+
@@ -19,8 +19,6 @@
135129
}
136130
referenceGrant: (#struct){
137131
foo: (#struct){
@@ -140,7 +134,7 @@ diff old new
140134
metadata: (#struct){
141135
name: (string){ |(*(string){ "foo" }, (string){ string }) }
142136
namespace: (string){ string }
143-
@@ -29,6 +30,8 @@
137+
@@ -29,6 +27,8 @@
144138
annotations?: (#struct){
145139
}
146140
}
@@ -149,25 +143,24 @@ diff old new
149143
}
150144
}
151145
}
152-
@@ -44,18 +47,6 @@
153-
}
146+
@@ -45,8 +45,6 @@
154147
}
155148
}
156-
- foo: (#struct){
149+
foo: (#struct){
157150
- apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" }
158151
- 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+
}
168162
}
169163
}
170-
}
171164
-- out/eval --
172165
(struct){
173166
issue3905: (struct){

0 commit comments

Comments
 (0)