cue: remove unify function
It was used inconcistently and its removal makes
it easier to find uses of opUnify and binOp.
Change-Id: I7fcf23a1105f52a512656c5b6e9710730d7da3f1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2705
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/binop.go b/cue/binop.go
index 1ac8c1b..b06ceb5 100644
--- a/cue/binop.go
+++ b/cue/binop.go
@@ -33,10 +33,6 @@
return baseValue{&computedSource{pos, op, a, b}}
}
-func unify(ctx *context, src source, left, right evaluated) evaluated {
- return binOp(ctx, src, opUnify, left, right)
-}
-
func binOp(ctx *context, src source, op op, left, right evaluated) (result evaluated) {
if b, ok := left.(*bottom); ok {
if op == opUnify && b.exprDepth == 0 && cycleError(b) != nil {
@@ -503,7 +499,6 @@
k, _, msg := matchBinOpKind(opUnify, x.kind(), other.kind())
if k == bottomKind {
return ctx.mkErr(src, msg, op, ctx.str(x), ctx.str(other), x.kind(), other.kind())
- break
}
switch y := other.(type) {
case *basicType:
@@ -1037,7 +1032,7 @@
break
}
- n := unify(ctx, src, x.len.(evaluated), y.len.(evaluated))
+ n := binOp(ctx, src, opUnify, x.len.(evaluated), y.len.(evaluated))
if isBottom(n) {
src = mkBin(ctx, src.Pos(), op, x, other)
return ctx.mkErr(src, "conflicting list lengths: %v", n)
@@ -1057,7 +1052,7 @@
max, ok := n.(*numLit)
if !ok || len(xa) < max.intValue(ctx) {
src := mkBin(ctx, src.Pos(), op, x.typ, y.typ)
- typ = unify(ctx, src, x.typ.(evaluated), y.typ.(evaluated))
+ typ = binOp(ctx, src, opUnify, x.typ.(evaluated), y.typ.(evaluated))
if isBottom(typ) {
return ctx.mkErr(src, "conflicting list element types: %v", typ)
}
@@ -1066,7 +1061,7 @@
// TODO: use forwarding instead of this mild hack.
x.elem.arcs = xa
y.elem.arcs = ya
- s := unify(ctx, src, x.elem, y.elem).(*structLit)
+ s := binOp(ctx, src, opUnify, x.elem, y.elem).(*structLit)
x.elem.arcs = sx
y.elem.arcs = sy
diff --git a/cue/value.go b/cue/value.go
index 859c930..c8f0997 100644
--- a/cue/value.go
+++ b/cue/value.go
@@ -1072,7 +1072,7 @@
// its own and does not depend on its input parameters.
arcs := make(arcs, len(x.arcs))
for i, a := range x.arcs {
- v := unify(ctx, p, a.v.evalPartial(ctx), args[i])
+ v := binOp(ctx, p, opUnify, a.v.evalPartial(ctx), args[i])
if isBottom(v) {
return v
}