diff --git a/cue/types.go b/cue/types.go index 7f246a81cff..87609d044b0 100644 --- a/cue/types.go +++ b/cue/types.go @@ -1710,9 +1710,9 @@ func allowed(ctx *adt.OpContext, parent, n *adt.Vertex) *adt.Bottom { func addConjuncts(dst, src *adt.Vertex) { c := adt.MakeRootConjunct(nil, src) - if src.Closed { + if src.ClosedRecursive { var root adt.CloseInfo - c.CloseInfo = root.SpawnRef(src, src.Closed, nil) + c.CloseInfo = root.SpawnRef(src, src.ClosedRecursive, nil) } dst.AddConjunct(c) } @@ -1738,7 +1738,7 @@ func (v Value) Unify(w Value) Value { n.Parent = v.v.Parent n.Label = v.v.Label - n.Closed = v.v.Closed || w.v.Closed + n.ClosedRecursive = v.v.ClosedRecursive || w.v.ClosedRecursive if err := n.Err(ctx); err != nil { return makeValue(v.idx, n, v.parent_) diff --git a/internal/core/adt/closed.go b/internal/core/adt/closed.go index fe2baf20043..6c639ef084e 100644 --- a/internal/core/adt/closed.go +++ b/internal/core/adt/closed.go @@ -84,7 +84,7 @@ func (v *Vertex) IsInOneOf(mask SpanType) bool { // IsRecursivelyClosed returns true if this value is either a definition or unified // with a definition. func (v *Vertex) IsRecursivelyClosed() bool { - return v.Closed || v.IsInOneOf(DefinitionSpan) + return v.ClosedRecursive || v.IsInOneOf(DefinitionSpan) } type closeNodeType uint8 @@ -330,7 +330,7 @@ func isClosed(v *Vertex) bool { // We could have used IsRecursivelyClosed here, but (effectively) // implementing it again here allows us to only have to iterate over // Structs once. - if v.Closed { + if v.ClosedRecursive { return true } for _, s := range v.Structs { diff --git a/internal/core/adt/composite.go b/internal/core/adt/composite.go index f952f463e5f..8eae8a41c52 100644 --- a/internal/core/adt/composite.go +++ b/internal/core/adt/composite.go @@ -182,10 +182,10 @@ type Vertex struct { // ignored. isData bool - // Closed indicates whether this Vertex is recursively closed. This is the - // case, for instance, if it is a node in a definition or if one of the - // conjuncts, or ancestor conjuncts, is a definition. - Closed bool + // ClosedRecursive indicates whether this Vertex is recursively closed. + // This is the case, for instance, if it is a node in a definition or if one + // of the conjuncts, or ancestor conjuncts, is a definition. + ClosedRecursive bool // HasEllipsis indicates that this Vertex is open by means of an ellipsis. // TODO: combine this field with Closed once we removed the old evaluator. @@ -1008,7 +1008,7 @@ func (v *Vertex) IsOptional(label Feature) bool { } func (v *Vertex) accepts(ok, required bool) bool { - return ok || (!required && !v.Closed) + return ok || (!required && !v.ClosedRecursive) } func (v *Vertex) IsClosedStruct() bool { @@ -1026,7 +1026,7 @@ func (v *Vertex) IsClosedStruct() bool { return false case *Vertex: - return v.Closed && !v.HasEllipsis + return v.ClosedRecursive && !v.HasEllipsis case *StructMarker: if x.NeedClose { diff --git a/internal/core/adt/conjunct.go b/internal/core/adt/conjunct.go index c1c9e044c95..b5adca0d5eb 100644 --- a/internal/core/adt/conjunct.go +++ b/internal/core/adt/conjunct.go @@ -119,7 +119,7 @@ func (n *nodeContext) scheduleConjunct(c Conjunct, id CloseInfo) { env := c.Env if id.cc.isDef { - n.node.Closed = true + n.node.ClosedRecursive = true } switch x := c.Elem().(type) { diff --git a/internal/core/adt/eval.go b/internal/core/adt/eval.go index 3f4f6001106..84f06c898bc 100644 --- a/internal/core/adt/eval.go +++ b/internal/core/adt/eval.go @@ -201,12 +201,12 @@ func (c *OpContext) unify(v *Vertex, flags combinedFlags) { case 0: if v.Label.IsDef() { - v.Closed = true + v.ClosedRecursive = true } if v.Parent != nil { - if v.Parent.Closed { - v.Closed = true + if v.Parent.ClosedRecursive { + v.ClosedRecursive = true } } @@ -794,7 +794,7 @@ func (n *nodeContext) checkClosed(state vertexStatus) bool { if !v.Label.IsInt() && v.Parent != nil && !ignore && v.ArcType <= ArcRequired { ctx := n.ctx // Visit arcs recursively to validate and compute error. - if _, err := verifyArc2(ctx, v.Label, v, v.Closed); err != nil { + if _, err := verifyArc2(ctx, v.Label, v, v.ClosedRecursive); err != nil { // Record error in child node to allow recording multiple // conflicts at the appropriate place, to allow valid fields to // be represented normally and, most importantly, to avoid diff --git a/internal/core/adt/share.go b/internal/core/adt/share.go index 099a72bcc6b..9cf1d77f40a 100644 --- a/internal/core/adt/share.go +++ b/internal/core/adt/share.go @@ -77,7 +77,7 @@ func (n *nodeContext) finalizeSharing() { n.node.Arcs = v.Arcs n.node.BaseValue = v.BaseValue n.node.status = v.status - n.node.Closed = v.Closed + n.node.ClosedRecursive = v.ClosedRecursive n.node.HasEllipsis = v.HasEllipsis } } @@ -146,7 +146,7 @@ func (n *nodeContext) shareIfPossible(c Conjunct, arc *Vertex, id CloseInfo) boo // probably a good idea anyway. // // TODO: come up with a mechanism to allow this case. - if n.node.Closed && !arc.Closed { + if n.node.ClosedRecursive && !arc.ClosedRecursive { return false } diff --git a/internal/core/adt/unify.go b/internal/core/adt/unify.go index 36cc488f2c9..bea759be906 100644 --- a/internal/core/adt/unify.go +++ b/internal/core/adt/unify.go @@ -77,12 +77,12 @@ func (n *nodeContext) initBare() { n.blockOn(scalarKnown | listTypeKnown | arcTypeKnown) if v.Label.IsDef() { - v.Closed = true + v.ClosedRecursive = true } if v.Parent != nil { - if v.Parent.Closed { - v.Closed = true + if v.Parent.ClosedRecursive { + v.ClosedRecursive = true } } } @@ -187,7 +187,7 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool { w := v.DerefDisjunct() if w != v { // Should resolve with dereference. - v.Closed = w.Closed + v.ClosedRecursive = w.ClosedRecursive v.status = w.status v.ChildErrors = CombineErrors(nil, v.ChildErrors, w.ChildErrors) v.Arcs = nil @@ -315,8 +315,8 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool { v.Arcs = nil // Set control fields that are referenced without dereferencing. - if w.Closed { - v.Closed = true + if w.ClosedRecursive { + v.ClosedRecursive = true } if w.HasEllipsis { v.HasEllipsis = true