Skip to content

Commit

Permalink
internal/core/adt: hacky alternative for cyclicReferences
Browse files Browse the repository at this point in the history
We did not yet implement cyclicReferences for the new
evaluator. This mechanism is an important aspect for performance.
It is hard to implement for the new evaluator, at least for now,
as we want to retain the flexibility of not having to evaluate
a referenced node first. Maybe later that is okay.
We implement an approximate alternative. This may give some
spurious structural cycles.
The idea is also that once we have structure sharing implemented,
we could probably implement a neater alternative to using
cyclicReferences.

Issue #2854
Issue #2884

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: If5f9b0d570cd8d122bd535e1fbc9b3ceafa848ba
  • Loading branch information
mpvl committed Apr 4, 2024
1 parent f1f3a64 commit 18b5944
Show file tree
Hide file tree
Showing 10 changed files with 1,618 additions and 281 deletions.
64 changes: 47 additions & 17 deletions cue/testdata/cycle/023_reentrance.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ Disjuncts: 268
Errors:
structural cycle:
./in.cue:3:25
structural cycle:
./in.cue:8:9
structural cycle:
./in.cue:8:38

Result:
(_|_){
Expand All @@ -100,35 +96,39 @@ Result:
n: (int){ int }
}
fib1: (int){ 1 }
fib2: (int){ 1 }
fib2: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
}
fib3: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
// structural cycle:
// ./in.cue:8:38
}
fib7: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
// structural cycle:
// ./in.cue:8:9
// structural cycle:
// ./in.cue:8:38
}
fib12: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
// structural cycle:
// ./in.cue:8:9
// structural cycle:
// ./in.cue:8:38
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -16,10 +16,6 @@
@@ -1,10 +1,6 @@
Errors:
structural cycle:
./in.cue:3:25
-structural cycle:
- ./in.cue:8:9
-structural cycle:
- ./in.cue:8:38

Result:
(_|_){
@@ -16,10 +12,6 @@
// ./in.cue:7:5
// ./in.cue:3:35
// ./in.cue:5:5
Expand All @@ -139,7 +139,7 @@ diff old new
}
}
fib: (_|_){
@@ -26,9 +22,6 @@
@@ -26,33 +18,23 @@
// [incomplete] fib: non-concrete value int in operand to >=:
// ./in.cue:7:5
// ./in.cue:5:5
Expand All @@ -149,6 +149,36 @@ diff old new
n: (int){ int }
}
fib1: (int){ 1 }
- fib2: (int){ 1 }
+ fib2: (_|_){
+ // [structural cycle] structural cycle:
+ // ./in.cue:3:25
+ }
fib3: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
- // structural cycle:
- // ./in.cue:8:38
}
fib7: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
- // structural cycle:
- // ./in.cue:8:9
- // structural cycle:
- // ./in.cue:8:38
}
fib12: (_|_){
// [structural cycle] structural cycle:
// ./in.cue:3:25
- // structural cycle:
- // ./in.cue:8:9
- // structural cycle:
- // ./in.cue:8:38
}
}
-- diff/todo/p3 --
Note that it is okay for fib2 to fail.
-- out/eval --
Errors:
structural cycle:
Expand Down
Loading

0 comments on commit 18b5944

Please sign in to comment.