From 3165a5e1aaecd3a76fa44ec0a3dac53801355101 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Wed, 23 Aug 2023 16:05:47 +0200 Subject: [PATCH] internal/core/adt: change slice type of notify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is to accomodate the new closedness algorithm. Doing this now makes upcoming diffs smaller. Signed-off-by: Marcel van Lohuizen Change-Id: I786318a39635dfeb7dd1dd1fc854521e474ffe03 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1167912 Reviewed-by: Daniel Martí Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo --- internal/core/adt/composite.go | 3 ++- internal/core/adt/eval.go | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/core/adt/composite.go b/internal/core/adt/composite.go index f5f71cd1ff4..8b089c014e3 100644 --- a/internal/core/adt/composite.go +++ b/internal/core/adt/composite.go @@ -999,7 +999,8 @@ func (n *nodeContext) addConjunctDynamic(c Conjunct) { } func (n *nodeContext) notifyConjunct(c Conjunct) { - for _, arc := range n.notify { + for _, rec := range n.notify { + arc := rec.v if !arc.hasConjunct(c) { if arc.state == nil { // TODO: continuing here is likely to result in a faulty diff --git a/internal/core/adt/eval.go b/internal/core/adt/eval.go index 8f299ca2b21..e43568ca0ed 100644 --- a/internal/core/adt/eval.go +++ b/internal/core/adt/eval.go @@ -138,7 +138,7 @@ func (c *OpContext) evaluate(v *Vertex, r Resolver, state vertexStatus) Value { // relax this again once we have proper tests to prevent regressions of // that issue. if !v.state.done() || v.state.errs != nil { - v.state.addNotify(c.vertex) + v.state.addNotify(c.vertex, nil) } } @@ -444,7 +444,8 @@ func (n *nodeContext) doNotify() { if n.errs == nil || len(n.notify) == 0 { return } - for _, v := range n.notify { + for _, rec := range n.notify { + v := rec.v if v.state == nil { if b, ok := v.BaseValue.(*Bottom); ok { v.BaseValue = CombineErrors(nil, b, n.errs) @@ -974,7 +975,7 @@ type nodeContext struct { // notify is used to communicate errors in cyclic dependencies. // TODO: also use this to communicate increasingly more concrete values. - notify []*Vertex + notify []receiver // Conjuncts holds a reference to the Vertex Arcs that still need // processing. It does NOT need to be copied. @@ -1062,6 +1063,12 @@ type nodeContextState struct { conjunctsPartialPos int } +// A receiver receives notifications. +type receiver struct { + v *Vertex + cc *closeContext +} + // Logf substitutes args in format. Arguments of type Feature, Value, and Expr // are printed in human-friendly formats. The printed string is prefixed and // indented with the path associated with the current nodeContext. @@ -1080,9 +1087,9 @@ type defaultInfo struct { origMode defaultMode } -func (n *nodeContext) addNotify(v *Vertex) { +func (n *nodeContext) addNotify(v *Vertex, cc *closeContext) { if v != nil && !n.node.hasAllConjuncts { - n.notify = append(n.notify, v) + n.notify = append(n.notify, receiver{v, cc}) } } @@ -1693,7 +1700,7 @@ func (n *nodeContext) addVertexConjuncts(c Conjunct, arc *Vertex, inline bool) { } if arc.state != nil { - arc.state.addNotify(n.node) + arc.state.addNotify(n.node, nil) } for _, c := range arc.Conjuncts {