Skip to content

Commit

Permalink
Revert "cue: remove Merge"
Browse files Browse the repository at this point in the history
This reverts https://cuelang.org/cl/1193719.

We broke `cue cmd ls ./...` in cuelang.org's k8s tutorial.
We will add a regression test and attempt these changes a second time.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie2e5ee2209cb5d2940d82ddf535125c815825faa
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193746
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
mvdan committed Apr 24, 2024
1 parent d9c6c75 commit 7195817
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cue/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,29 @@ func (inst *hiddenInstance) Eval(expr ast.Expr) Value {
return v.Context().BuildExpr(expr, Scope(v), InferBuiltins(true))
}

// DO NOT USE.
//
// Deprecated: do not use.
func Merge(inst ...*Instance) *Instance {
v := &adt.Vertex{}

i := inst[0]
ctx := newContext(i.index)

// TODO: interesting test: use actual unification and then on K8s corpus.

for _, i := range inst {
w := i.Value()
v.AddConjunct(adt.MakeRootConjunct(nil, w.v.ToDataAll(ctx)))
}
v.Finalize(ctx)

p := addInst(i.index, &Instance{
root: v,
})
return p
}

// Build creates a new instance from the build instances, allowing unbound
// identifier to bind to the top-level field in inst. The top-level fields in
// inst take precedence over predeclared identifier and builtin functions.
Expand Down

0 comments on commit 7195817

Please sign in to comment.