Skip to content

Commit fb37710

Browse files
committed
internal/core/adt: introduce new cycle detection mechanism
The old evaluator used Vertex.status for tracking processing states. This was used to track cycles as well. The status was set to "evaluating" when evaluating values at the same level. A node that appeared with this status during computation indicated an evaluation cycle. The status was set to "evaluatingArc" while processing a child arc. A node that appeared with this status during processing indicated a structural cycle. The status mechanism turned out to be broken, and the new evaluator doesn't really use it much anymore. The goal is to get rid of it altogether. This CL introduces a new mechansim to replace the "evaluatingArcs" and "evaluating" modes. The new mechanism is higher fidelity than the old mechanism. It is currently only used in a few locations, though. Down the line, possibly only once the old evaluator is removed, we intend to fully discard the old mechanism. Issue #2884 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ifbe99e0b6dbd782d1f81f7d5d19c0f7479be0afb Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193842 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 1dda583 commit fb37710

File tree

8 files changed

+373
-92
lines changed

8 files changed

+373
-92
lines changed

cue/testdata/cycle/comprehension.txtar

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,15 @@ issue1881.p2.o.retry: field not allowed:
360360
./in.cue:217:17
361361
issue1881.p2.2.retry: structural cycle:
362362
./in.cue:219:14
363+
issue1881.p2.2.retry.output: structural cycle:
364+
./in.cue:219:14
363365
issue1881.p3.o.retry: field not allowed:
364366
./in.cue:231:11
365367
./in.cue:235:17
366368
issue1881.p3.2.retry: structural cycle:
367369
./in.cue:231:14
370+
issue1881.p3.2.retry.output: structural cycle:
371+
./in.cue:231:14
368372
siblingInsertion.t2.p1.deployment: adding field logging not allowed as field set was already referenced:
369373
./in.cue:277:21
370374
siblingInsertion.t2.p2.deployment: adding field logging not allowed as field set was already referenced:
@@ -717,7 +721,7 @@ Result:
717721
// [eval] issue1881.p2.o.retry: field not allowed:
718722
// ./in.cue:219:11
719723
// ./in.cue:217:17
720-
// issue1881.p2.2.retry: structural cycle:
724+
// issue1881.p2.2.retry.output: structural cycle:
721725
// ./in.cue:219:14
722726
retry: (_|_){
723727
// [eval] issue1881.p2.o.retry: field not allowed:
@@ -750,7 +754,7 @@ Result:
750754
// [eval] issue1881.p3.o.retry: field not allowed:
751755
// ./in.cue:231:11
752756
// ./in.cue:235:17
753-
// issue1881.p3.2.retry: structural cycle:
757+
// issue1881.p3.2.retry.output: structural cycle:
754758
// ./in.cue:231:14
755759
retry: (_|_){
756760
// [eval] issue1881.p3.o.retry: field not allowed:
@@ -829,7 +833,7 @@ Result:
829833
diff old new
830834
--- old
831835
+++ new
832-
@@ -1,5 +1,54 @@
836+
@@ -1,5 +1,58 @@
833837
Errors:
834838
-selfReferential.insertionError.A: field foo3 not allowed by earlier comprehension or reference cycle
835839
+issue1881.p1.o.retry: field not allowed:
@@ -871,11 +875,15 @@ diff old new
871875
+ ./in.cue:217:17
872876
+issue1881.p2.2.retry: structural cycle:
873877
+ ./in.cue:219:14
878+
+issue1881.p2.2.retry.output: structural cycle:
879+
+ ./in.cue:219:14
874880
+issue1881.p3.o.retry: field not allowed:
875881
+ ./in.cue:231:11
876882
+ ./in.cue:235:17
877883
+issue1881.p3.2.retry: structural cycle:
878884
+ ./in.cue:231:14
885+
+issue1881.p3.2.retry.output: structural cycle:
886+
+ ./in.cue:231:14
879887
+siblingInsertion.t2.p1.deployment: adding field logging not allowed as field set was already referenced:
880888
+ ./in.cue:277:21
881889
+siblingInsertion.t2.p2.deployment: adding field logging not allowed as field set was already referenced:
@@ -885,7 +893,7 @@ diff old new
885893

886894
Result:
887895
(_|_){
888-
@@ -19,7 +68,9 @@
896+
@@ -19,7 +72,9 @@
889897
B: (struct){
890898
a: (struct){
891899
parent: (string){ "" }
@@ -896,7 +904,7 @@ diff old new
896904
}
897905
}
898906
}
899-
@@ -52,17 +103,17 @@
907+
@@ -52,17 +107,17 @@
900908
}
901909
}
902910
_e: (#struct){
@@ -925,7 +933,7 @@ diff old new
925933
}
926934
}
927935
e: (#struct){
928-
@@ -112,15 +163,14 @@
936+
@@ -112,15 +167,14 @@
929937
}
930938
}
931939
list: (struct){
@@ -944,7 +952,7 @@ diff old new
944952
}
945953
}
946954
}
947-
@@ -127,208 +177,269 @@
955+
@@ -127,208 +181,269 @@
948956
insertionError: (_|_){
949957
// [eval]
950958
A: (_|_){
@@ -1355,7 +1363,7 @@ diff old new
13551363
+ // [eval] issue1881.p2.o.retry: field not allowed:
13561364
+ // ./in.cue:219:11
13571365
+ // ./in.cue:217:17
1358-
+ // issue1881.p2.2.retry: structural cycle:
1366+
+ // issue1881.p2.2.retry.output: structural cycle:
13591367
+ // ./in.cue:219:14
13601368
+ retry: (_|_){
13611369
+ // [eval] issue1881.p2.o.retry: field not allowed:
@@ -1388,7 +1396,7 @@ diff old new
13881396
+ // [eval] issue1881.p3.o.retry: field not allowed:
13891397
+ // ./in.cue:231:11
13901398
+ // ./in.cue:235:17
1391-
+ // issue1881.p3.2.retry: structural cycle:
1399+
+ // issue1881.p3.2.retry.output: structural cycle:
13921400
+ // ./in.cue:231:14
13931401
+ retry: (_|_){
13941402
+ // [eval] issue1881.p3.o.retry: field not allowed:
@@ -1403,7 +1411,7 @@ diff old new
14031411
t1: (struct){
14041412
p1: (struct){
14051413
D: (struct){
1406-
@@ -361,40 +472,34 @@
1414+
@@ -361,40 +476,34 @@
14071415
}
14081416
}
14091417
}

0 commit comments

Comments
 (0)