internal/core/adt: remove special "tentative" mode
The new AllArcs state is sufficient to indicate the
partial evaluation needed for processing comprehensions.
The old special-casing through the tentative mode is thus
no longer needed.
Change-Id: I851b063cf886f053e7f71a0407471f53ceadada9
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8162
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/core/adt/context.go b/internal/core/adt/context.go
index 5b02207..e1c4f9b 100644
--- a/internal/core/adt/context.go
+++ b/internal/core/adt/context.go
@@ -166,10 +166,6 @@
// structural cycle errors.
vertex *Vertex
- // TODO: remove use of tentative. Should be possible if incomplete
- // handling is done better.
- tentative int // set during comprehension evaluation
-
// These fields are used associate scratch fields for computing closedness
// of a Vertex. These fields could have been included in StructInfo (like
// Tomabechi's unification algorithm), but we opted for an indirection to
@@ -188,12 +184,6 @@
return c.Runtime
}
-// If IsTentative is set, evaluation of an arc should not finalize
-// to non-concrete values.
-func (c *OpContext) IsTentative() bool {
- return c.tentative > 0
-}
-
func (c *OpContext) Pos() token.Pos {
if c.src == nil {
return token.NoPos
@@ -431,12 +421,8 @@
func (c *OpContext) Yield(env *Environment, y Yielder, f YieldFunc) *Bottom {
s := c.PushState(env, y.Source())
- c.tentative++
-
y.yield(c, f)
- c.tentative--
-
return c.PopState(s)
}
diff --git a/internal/core/adt/eval.go b/internal/core/adt/eval.go
index 47037db..879528d 100644
--- a/internal/core/adt/eval.go
+++ b/internal/core/adt/eval.go
@@ -152,24 +152,6 @@
switch x := v.BaseValue.(type) {
case *Bottom:
return x
- case *Disjunction:
- if x.NumDefaults == 1 {
- if c.IsTentative() && isStruct(v) {
- // TODO(perf): do something more efficient perhaps? This discards
- // the computed arcs so far. Instead, we could have a separate
- // marker to accumulate results. As this only happens within
- // comprehensions, the effect is likely minimal, though.
- arcs := v.Arcs
- w := &Vertex{
- Parent: v.Parent,
- BaseValue: &StructMarker{},
- Arcs: arcs,
- Conjuncts: v.Conjuncts,
- }
- w.UpdateStatus(v.Status())
- v = w
- }
- }
case nil:
if v.state != nil {
@@ -433,7 +415,7 @@
default:
if n.node.BaseValue == cycle {
- if !n.done() { // && !ctx.IsTentative() {
+ if !n.done() {
// collect incomplete errors.
var err *Bottom // n.incomplete
for _, d := range n.dynamicFields {