Skip to content

Commit 8e02b92

Browse files
committed
internal/core/adt: split conjunct trees based on prefix
Before this change, any conjunct referred to was inserted at the insertion point in full. Top-level conjuncts have a tree representing the origin of their definition and embedding. This caused the closedness rules to be repeated when they should not, resulting in spurious "field not allowed" errors. The new algorithm splits a conjunct into branches with roots that are shared with the insertion point removed. This ensures that references that are in scope of a definition do not get spuriously inserted. Fixes #3330 Fixes #3331 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I7a573f9576d3c46374647045d8ec226a1cd543b3 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199272 Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 53bbdad commit 8e02b92

16 files changed

+211
-386
lines changed

cue/testdata/benchmarks/inlinedisjunction.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Allocs: 147
2121
Retain: 0
2222

2323
Unifications: 17
24-
Conjuncts: 199
24+
Conjuncts: 198
2525
Disjuncts: 76
2626
-- out/eval --
2727
(struct){
@@ -60,7 +60,7 @@ diff old new
6060
-Conjuncts: 13409
6161
-Disjuncts: 4674
6262
+Unifications: 17
63-
+Conjuncts: 199
63+
+Conjuncts: 198
6464
+Disjuncts: 76
6565
-- out/eval/stats --
6666
Leaks: 0

cue/testdata/benchmarks/issue1684.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Allocs: 2533
6969
Retain: 0
7070

7171
Unifications: 707
72-
Conjuncts: 5878
72+
Conjuncts: 5373
7373
Disjuncts: 1102
7474
-- out/evalalpha --
7575
(struct){
@@ -159,7 +159,7 @@ diff old new
159159
-Conjuncts: 2480117
160160
-Disjuncts: 1064333
161161
+Unifications: 707
162-
+Conjuncts: 5878
162+
+Conjuncts: 5373
163163
+Disjuncts: 1102
164164
-- diff/-out/evalalpha<==>+out/eval --
165165
diff old new

cue/testdata/benchmarks/listdedup.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Allocs: 163
4040
Retain: 0
4141

4242
Unifications: 53
43-
Conjuncts: 431
43+
Conjuncts: 407
4444
Disjuncts: 40
4545
-- out/eval --
4646
(struct){
@@ -226,7 +226,7 @@ diff old new
226226
-Conjuncts: 100730
227227
-Disjuncts: 24097
228228
+Unifications: 53
229-
+Conjuncts: 431
229+
+Conjuncts: 407
230230
+Disjuncts: 40
231231
-- out/eval/stats --
232232
Leaks: 0

cue/testdata/cycle/023_reentrance.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Allocs: 70
7070
Retain: 0
7171

7272
Unifications: 62
73-
Conjuncts: 227
73+
Conjuncts: 225
7474
Disjuncts: 0
7575
-- out/evalalpha --
7676
Errors:
@@ -133,7 +133,7 @@ diff old new
133133
-Conjuncts: 464
134134
-Disjuncts: 268
135135
+Unifications: 62
136-
+Conjuncts: 227
136+
+Conjuncts: 225
137137
+Disjuncts: 0
138138
-- diff/-out/evalalpha<==>+out/eval --
139139
diff old new

cue/testdata/cycle/chain.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Allocs: 19986
215215
Retain: 0
216216

217217
Unifications: 7496
218-
Conjuncts: 107561
218+
Conjuncts: 107414
219219
Disjuncts: 13651
220220
-- out/evalalpha --
221221
Errors:
@@ -735,7 +735,7 @@ diff old new
735735
-Conjuncts: 3175
736736
-Disjuncts: 1974
737737
+Unifications: 7496
738-
+Conjuncts: 107561
738+
+Conjuncts: 107414
739739
+Disjuncts: 13651
740740
-- diff/-out/evalalpha<==>+out/eval --
741741
diff old new

cue/testdata/cycle/inline_non_recursive.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Allocs: 209
6767
Retain: 0
6868

6969
Unifications: 194
70-
Conjuncts: 1097
70+
Conjuncts: 1034
7171
Disjuncts: 0
7272
-- out/evalalpha --
7373
Errors:
@@ -203,7 +203,7 @@ diff old new
203203
-Conjuncts: 2709
204204
-Disjuncts: 1414
205205
+Unifications: 194
206-
+Conjuncts: 1097
206+
+Conjuncts: 1034
207207
+Disjuncts: 0
208208
-- diff/-out/evalalpha<==>+out/eval --
209209
diff old new

cue/testdata/cycle/issue990.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ Allocs: 2198
626626
Retain: 0
627627

628628
Unifications: 219
629-
Conjuncts: 8714
629+
Conjuncts: 6776
630630
Disjuncts: 462
631631
-- out/evalalpha --
632632
Errors:
@@ -816,7 +816,7 @@ diff old new
816816
-Conjuncts: 12056
817817
-Disjuncts: 3258
818818
+Unifications: 219
819-
+Conjuncts: 8714
819+
+Conjuncts: 6776
820820
+Disjuncts: 462
821821
-- diff/-out/evalalpha<==>+out/eval --
822822
diff old new

0 commit comments

Comments
 (0)