From ab1e2d9ed3299c08854e94250a39c0c40c741779 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Mon, 10 Feb 2025 16:26:35 +0100 Subject: [PATCH] internal/core/adt: remove GroupUnify mechanism MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This mechanism was originally added to deal with closedness issues around Unify. These have now been addressed differently with various fixes, allowing this mechanism to be removed. Issue #3706 Signed-off-by: Marcel van Lohuizen Change-Id: Ic5a2358351e0c3126cbbf59eab6246f30ab49f1a Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1208588 TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí --- cue/testdata/cycle/builtins.txtar | 4 ++-- cue/testdata/cycle/inline_non_recursive.txtar | 4 ++-- internal/core/adt/closed.go | 5 ----- internal/core/adt/composite.go | 1 - internal/core/adt/conjunct.go | 3 ++- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cue/testdata/cycle/builtins.txtar b/cue/testdata/cycle/builtins.txtar index 7406964cbb7..f0c42995538 100644 --- a/cue/testdata/cycle/builtins.txtar +++ b/cue/testdata/cycle/builtins.txtar @@ -216,7 +216,7 @@ Allocs: 351 Retain: 0 Unifications: 310 -Conjuncts: 1273 +Conjuncts: 1216 Disjuncts: 28 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- diff old new @@ -238,7 +238,7 @@ diff old new -Conjuncts: 625 -Disjuncts: 441 +Unifications: 310 -+Conjuncts: 1273 ++Conjuncts: 1216 +Disjuncts: 28 -- out/eval/stats -- Leaks: 23 diff --git a/cue/testdata/cycle/inline_non_recursive.txtar b/cue/testdata/cycle/inline_non_recursive.txtar index 8459013351f..88f889b0d59 100644 --- a/cue/testdata/cycle/inline_non_recursive.txtar +++ b/cue/testdata/cycle/inline_non_recursive.txtar @@ -101,7 +101,7 @@ Allocs: 228 Retain: 0 Unifications: 183 -Conjuncts: 828 +Conjuncts: 827 Disjuncts: 0 -- out/evalalpha -- Errors: @@ -252,7 +252,7 @@ diff old new -Conjuncts: 2813 -Disjuncts: 1485 +Unifications: 183 -+Conjuncts: 828 ++Conjuncts: 827 +Disjuncts: 0 -- diff/-out/evalalpha<==>+out/eval -- diff old new diff --git a/internal/core/adt/closed.go b/internal/core/adt/closed.go index 6db1eebf18b..054bff35384 100644 --- a/internal/core/adt/closed.go +++ b/internal/core/adt/closed.go @@ -122,11 +122,6 @@ type CloseInfo struct { // NOTE: only used when using closeContext. FromDef bool - // GroupUnify indicates that this conjunct needs to spawn its own - // closeContext. This is necessary when programmatically combining - // top-level values, such as with Value.Unify. - GroupUnify bool - // FieldTypes indicates which kinds of fields (optional, dynamic, patterns, // etc.) are contained in this conjunct. FieldTypes OptionalType diff --git a/internal/core/adt/composite.go b/internal/core/adt/composite.go index 7149394cd66..46379600a12 100644 --- a/internal/core/adt/composite.go +++ b/internal/core/adt/composite.go @@ -992,7 +992,6 @@ func Unify(c *OpContext, a, b Value) *Vertex { func addConjuncts(ctx *OpContext, dst *Vertex, src Value) { closeInfo := ctx.CloseInfo() c := MakeConjunct(nil, src, closeInfo) - c.CloseInfo.GroupUnify = true if v, ok := src.(*Vertex); ok && v.ClosedRecursive { if ctx.Version == internal.EvalV2 { diff --git a/internal/core/adt/conjunct.go b/internal/core/adt/conjunct.go index 05b2214253a..a8977452069 100644 --- a/internal/core/adt/conjunct.go +++ b/internal/core/adt/conjunct.go @@ -92,9 +92,10 @@ func (n *nodeContext) scheduleConjunct(c Conjunct, id CloseInfo) { id.FromEmbed = false } } - if t != 0 || c.CloseInfo.GroupUnify { + if t != 0 { id, _ = id.spawnCloseContext(n.ctx, t) } + if !id.cc.done { id.cc.incDependent(n.ctx, DEFER, nil) defer id.cc.decDependent(n.ctx, DEFER, nil)