Skip to content

Commit f752335

Browse files
committed
internal/core/adt: force finalizing of shared values
When finalizing a value, CUE currently only finalized direct arcs and skipped shared values. The reasoning there is that CUE will anyway evaluated these shared values eventually as the stack unwinds, meaning that at the end of a CUE evaluation, all these shared values are evaluated anyway. However, this logic does not hold for builtins: if a value is passed to a builtin mid evaluation, a shared value may still be unprocessed. Basically, because evaluation has not finished yet, there is no guarantee that shared values are finalized. We now ensure that all shared values comply to the same requirements as those for the current node under evaluation. This fixes the tests added for 3648, but also removes some discrepancies between V2 and V3. In one case in particular, constraints.txtar:brokenRing, this CL reverses a fix and now makes V3 mimic the same bug as V2. We will accept this regression as not particularly harmful and the net result is certainly positive. Fixes #3648 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ie877e7d94107841e0d9cbcf8b6ecdbcfcde5676b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207912 Reviewed-by: Matthew Sackman <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 72c7c27 commit f752335

File tree

6 files changed

+156
-291
lines changed

6 files changed

+156
-291
lines changed

cue/testdata/cycle/comprehension.txtar

+14-65
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ issue2367: {
310310
}
311311

312312
-- out/evalalpha/stats --
313-
Leaks: 782
314-
Freed: 63
315-
Reused: 63
316-
Allocs: 782
313+
Leaks: 777
314+
Freed: 68
315+
Reused: 68
316+
Allocs: 777
317317
Retain: 0
318318

319319
Unifications: 502
@@ -583,17 +583,13 @@ Result:
583583
reject: (string){ string }
584584
}, (#struct){
585585
resource: (string){ string }
586-
}, (#struct){
587-
retry: ~(issue1881.p1.#AllOutputs.retry)
588586
}) }
589587
}
590588
}
591589
#Output: (#struct){ |((#struct){
592590
reject: (string){ string }
593591
}, (#struct){
594592
resource: (string){ string }
595-
}, (#struct){
596-
retry: ~(issue1881.p1.#AllOutputs.retry)
597593
}) }
598594
}
599595
p2: (struct){
@@ -790,60 +786,16 @@ diff old new
790786
}
791787
}
792788
acrossOr: (struct){
793-
@@ -254,27 +247,31 @@
789+
@@ -254,7 +247,7 @@
794790
issue1881: (struct){
795791
p1: (struct){
796792
o: (#struct){
797793
- retry: (#struct){
798-
- output: (#struct){
799-
- reject: (string){ "ok" }
800-
- }
801-
- }
802-
- }
803-
- #AllOutputs: (#struct){
804-
- reject: (string){ string }
805-
- resource: (string){ string }
806-
- retry: (#struct){
807-
- output: (#struct){ |((#struct){
808-
- reject: (string){ string }
809-
- }, (#struct){
810-
- resource: (string){ string }
811-
- }) }
812-
- }
813-
- }
814-
- #Output: (#struct){ |((#struct){
815-
- reject: (string){ string }
816-
- }, (#struct){
817-
- resource: (string){ string }
818794
+ retry: (struct){
819-
+ output: (#struct){
820-
+ reject: (string){ "ok" }
821-
+ }
822-
+ }
823-
+ }
824-
+ #AllOutputs: (#struct){
825-
+ reject: (string){ string }
826-
+ resource: (string){ string }
827-
+ retry: (#struct){
828-
+ output: (#struct){ |((#struct){
829-
+ reject: (string){ string }
830-
+ }, (#struct){
831-
+ resource: (string){ string }
832-
+ }, (#struct){
833-
+ retry: ~(issue1881.p1.#AllOutputs.retry)
834-
+ }) }
835-
+ }
836-
+ }
837-
+ #Output: (#struct){ |((#struct){
838-
+ reject: (string){ string }
839-
+ }, (#struct){
840-
+ resource: (string){ string }
841-
+ }, (#struct){
842-
+ retry: ~(issue1881.p1.#AllOutputs.retry)
843-
}) }
844-
}
845-
p2: (struct){
846-
@@ -290,7 +287,7 @@
795+
output: (#struct){
796+
reject: (string){ "ok" }
797+
}
798+
@@ -290,7 +283,7 @@
847799
}
848800
}
849801
o: (#struct){
@@ -852,7 +804,7 @@ diff old new
852804
output: (#struct){
853805
reject: (string){ "ok" }
854806
}
855-
@@ -320,7 +317,7 @@
807+
@@ -320,7 +313,7 @@
856808
resource: (string){ string }
857809
}) }
858810
o: (#struct){
@@ -871,10 +823,10 @@ diff old new
871823
-Reused: 1260
872824
-Allocs: 60
873825
-Retain: 145
874-
+Leaks: 782
875-
+Freed: 63
876-
+Reused: 63
877-
+Allocs: 782
826+
+Leaks: 777
827+
+Freed: 68
828+
+Reused: 68
829+
+Allocs: 777
878830
+Retain: 0
879831

880832
-Unifications: 832
@@ -895,9 +847,6 @@ Conjuncts: 2525
895847
Disjuncts: 1404
896848
-- diff/explanation --
897849
B.a.children: now correctly marked as incomplete
898-
-- diff/todo/p2 --
899-
issue1881.#AllOutputs.retry: additional entry.
900-
Might be error in practice and okay.
901850
-- out/eval --
902851
Errors:
903852
selfReferential.insertionError.A: field foo3 not allowed by earlier comprehension or reference cycle

0 commit comments

Comments
 (0)