cue: fix bug in type inference
used wrong type inference function for numbers
Fixes #107
Change-Id: Ia215bffdf368ef2d96a19a8c7b2c7437c2af5d66
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3280
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/binop.go b/cue/binop.go
index f5a8e44..2d0f849 100644
--- a/cue/binop.go
+++ b/cue/binop.go
@@ -933,7 +933,7 @@
return y.binOp(ctx, src, op, x)
}
case *numLit:
- k := unifyType(x.kind(), y.kind())
+ k, _, _ := matchBinOpKind(op, x.kind(), y.kind())
n := newNumBin(k, x, y)
switch op {
case opUnify, opUnifyUnchecked:
diff --git a/cue/types_test.go b/cue/types_test.go
index 2503949..efc384d 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -1792,6 +1792,10 @@
// are optional
value: `{foo?: bar, bar?: foo, baz: 3}`,
json: `{"baz":3}`,
+ }, {
+ // Issue #107
+ value: `a: 1.0/1`,
+ json: `{"a":1}`,
}}
for i, tc := range testCases {
t.Run(fmt.Sprintf("%d/%v", i, tc.value), func(t *testing.T) {