Skip to content

Commit 0e1e7b5

Browse files
committed
internal/core/eval: small cleanup of evaluation code
in preparation of rewrite of disjunction algorithm Change-Id: I725062ec004198fbe4b2194ee2c612e2ae7186ea Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8046 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent cea55b2 commit 0e1e7b5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

internal/core/eval/disjunct.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ func (n *nodeContext) addDisjunctionValue(env *adt.Environment, x *adt.Disjuncti
131131
func (n *nodeContext) updateResult(state adt.VertexStatus) (isFinal bool) {
132132
n.postDisjunct(state)
133133

134-
x := n.node
135134
if n.hasErr() {
135+
x := n.node
136136
err, ok := x.BaseValue.(*adt.Bottom)
137137
if !ok {
138138
err = n.getErr()
@@ -166,7 +166,7 @@ func (n *nodeContext) updateResult(state adt.VertexStatus) (isFinal bool) {
166166
p := &result
167167
d.Values = append(d.Values, p)
168168

169-
if n.done() && (!n.isDefault() || n.isDefault()) {
169+
if n.done() {
170170
n.nodeShared.isDone = true
171171
}
172172

internal/core/eval/eval.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func (e *Evaluator) Evaluate(c *adt.OpContext, v *adt.Vertex) adt.Value {
200200
clone := *(d.Values[last])
201201
d.Values[last] = &clone
202202

203+
v.UpdateStatus(adt.Finalized)
203204
v.BaseValue = d
204205
v.Arcs = nil
205206
v.Structs = nil // TODO: maybe not do this.
@@ -344,7 +345,6 @@ func (e *Evaluator) evalVertex(c *adt.OpContext, v *adt.Vertex, state adt.Vertex
344345
// conflicts at the appropriate place, to allow valid fields to
345346
// be represented normally and, most importantly, to avoid
346347
// recursive processing of a disallowed field.
347-
v.BaseValue = err
348348
v.SetValue(c, adt.Finalized, err)
349349
return shared
350350
}
@@ -684,7 +684,8 @@ func (n *nodeShared) createDisjunct() *adt.Disjunction {
684684
}
685685

686686
func (n *nodeShared) result() *adt.Vertex {
687-
return &n.result_
687+
x := n.result_
688+
return &x
688689
}
689690

690691
func (n *nodeShared) setResult(v *adt.Vertex) {

0 commit comments

Comments
 (0)