Skip to content

Commit e4c4b8e

Browse files
committedDec 20, 2024·
internal/core/adt: dereference disjunct result
With nested disjunctions, disjuncts may end up forwarded in Vertex.BaseValue in intermediate results. This causes closeContext.arcs and Arcs to be misaligned if these results are used in further processing. This is the case, for instance in the following example: {#v: 1} | 2 {#v: 1} | (2 | 3) {#v: 1} | 2 {#v: 1} | 2 This issue led to duplicate disjuncts and many other problems. The EvalAlpha test runs over 10% faster as a result of this change! The test in conjuncts.txtar removes a spurious element and is now correct. The tests for 3528 were already fixed by an earlier CL. We will leave the closing here, though, to signal these changes are related. Fixes #3528 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ieaeba4b758006592b115240dac2e29b967103c5a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206178 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 8f55942 commit e4c4b8e

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed
 

‎cue/testdata/eval/conjuncts.txtar

+14-14
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ issue2355: {
6969
}
7070

7171
-- out/evalalpha/stats --
72-
Leaks: 187
73-
Freed: 25
74-
Reused: 25
75-
Allocs: 187
72+
Leaks: 216
73+
Freed: 30
74+
Reused: 30
75+
Allocs: 216
7676
Retain: 0
7777

7878
Unifications: 43
79-
Conjuncts: 350
80-
Disjuncts: 124
79+
Conjuncts: 378
80+
Disjuncts: 152
8181
-- out/evalalpha --
8282
Errors:
8383
param: conflicting values "foo" and [{}] (mismatched types string and list):
@@ -102,7 +102,7 @@ Result:
102102
string
103103
#early: (string){ |(*(string){ "X" }, (string){ string }) }
104104
}) }
105-
t3: (string){ |(*(string){ "X" }, (string){
105+
t3: (string){ |(*(string){
106106
"X"
107107
#early: (string){ |(*(string){ "X" }, (string){ string }) }
108108
}, (string){
@@ -163,18 +163,18 @@ diff old new
163163
-Reused: 59
164164
-Allocs: 18
165165
-Retain: 22
166-
+Leaks: 187
167-
+Freed: 25
168-
+Reused: 25
169-
+Allocs: 187
166+
+Leaks: 216
167+
+Freed: 30
168+
+Reused: 30
169+
+Allocs: 216
170170
+Retain: 0
171171

172172
-Unifications: 45
173173
-Conjuncts: 135
174174
-Disjuncts: 86
175175
+Unifications: 43
176-
+Conjuncts: 350
177-
+Disjuncts: 124
176+
+Conjuncts: 378
177+
+Disjuncts: 152
178178
-- diff/-out/evalalpha<==>+out/eval --
179179
diff old new
180180
--- old
@@ -200,7 +200,7 @@ diff old new
200200
- // ./in.cue:15:2
201201
- #early: (string){ |(*(string){ "X" }, (string){ string }) }
202202
- }
203-
+ t3: (string){ |(*(string){ "X" }, (string){
203+
+ t3: (string){ |(*(string){
204204
+ "X"
205205
+ #early: (string){ |(*(string){ "X" }, (string){ string }) }
206206
+ }, (string){

‎internal/core/adt/disjunct2.go

+2
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ func (n *nodeContext) doDisjunct(c Conjunct, m defaultMode, mode runMode) (*node
451451
return nil, err
452452
}
453453

454+
d = d.node.DerefDisjunct().state
455+
454456
return d, nil
455457
}
456458

‎internal/core/adt/eval_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var skipDebugDepErrors = map[string]int{
8888
"disjunctions/edge": 1,
8989
"disjunctions/elimination": 11,
9090
"disjunctions/embed": 6,
91-
"eval/conjuncts": 4,
91+
"eval/conjuncts": 3,
9292
"eval/notify": 17,
9393
"fulleval/054_issue312": 1,
9494
"scalars/embed": 1,

0 commit comments

Comments
 (0)
Please sign in to comment.