cue: simplify type annotation for better errors
Issue #52
The current annotations for references and non-ground
values are confusing. Removing them results in better
errors.
Change-Id: I827e0face21255e39336d18b4fbb2693b5407226
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2167
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cmd/cue/cmd/testdata/tasks/cmd_baddisplay.out b/cmd/cue/cmd/testdata/tasks/cmd_baddisplay.out
index c08a05b..c691b70 100644
--- a/cmd/cue/cmd/testdata/tasks/cmd_baddisplay.out
+++ b/cmd/cue/cmd/testdata/tasks/cmd_baddisplay.out
@@ -1,4 +1,4 @@
-unsupported op &(int, (string)*):
+unsupported op &(int, string):
$CWD/testdata/tasks/task_tool.cue:29:9
tool/cli:4:9
diff --git a/cue/kind.go b/cue/kind.go
index b8b3b37..ea4aad8 100644
--- a/cue/kind.go
+++ b/cue/kind.go
@@ -145,12 +145,6 @@
if str == "" {
return "_|_"
}
- if k&nonGround != 0 {
- str = "(" + str + ")*"
- }
- if k&referenceKind != 0 {
- str = "&" + str
- }
return str
}
diff --git a/cue/resolve_test.go b/cue/resolve_test.go
index d54784b..e645a6a 100644
--- a/cue/resolve_test.go
+++ b/cue/resolve_test.go
@@ -141,7 +141,7 @@
`e1: _|_(("foo" =~ 1):unsupported op =~(string, int)), ` +
`e2: _|_(("foo" !~ true):unsupported op !~(string, bool)), ` +
- `e3: _|_((!="a" & <5):unsupported op &((string)*, (number)*))}`,
+ `e3: _|_((!="a" & <5):unsupported op &(string, number))}`,
}, {
desc: "arithmetic",
in: `
@@ -271,7 +271,7 @@
f: true
f: bool
`,
- out: `<0>{a: 1, b: 1, c: 1.0, d: _|_((int & float):unsupported op &((int)*, (float)*)), e: "4", f: true}`,
+ out: `<0>{a: 1, b: 1, c: 1.0, d: _|_((int & float):unsupported op &(int, float)), e: "4", f: true}`,
}, {
desc: "strings and bytes",
in: `
@@ -439,7 +439,7 @@
p: +true
m: -false
`,
- out: `<0>{i: int, j: 3, s: string, t: "s", e: _|_((int & string):unsupported op &((int)*, (string)*)), e2: _|_((1 & string):unsupported op &(int, (string)*)), b: _|_(!int:unary '!' requires bool value, found (int)*), p: _|_(+true:unary '+' requires numeric value, found bool), m: _|_(-false:unary '-' requires numeric value, found bool)}`,
+ out: `<0>{i: int, j: 3, s: string, t: "s", e: _|_((int & string):unsupported op &(int, string)), e2: _|_((1 & string):unsupported op &(int, string)), b: _|_(!int:unary '!' requires bool value, found int), p: _|_(+true:unary '+' requires numeric value, found bool), m: _|_(-false:unary '-' requires numeric value, found bool)}`,
}, {
desc: "comparison",
in: `
@@ -598,7 +598,7 @@
e1: 2.0 % (3&int)
e2: int & 4.0/2.0
`,
- out: `<0>{v1: 5e+11, v2: true, n1: 1, v5: 2, e1: 2.0, e2: _|_((int & 2):unsupported op &((int)*, float))}`,
+ out: `<0>{v1: 5e+11, v2: true, n1: 1, v5: 2, e1: 2.0, e2: _|_((int & 2):unsupported op &(int, float))}`,
}, {
desc: "inequality",
in: `
@@ -737,7 +737,7 @@
`e6: _|_(incompatible bounds >11 and <11), ` +
`e7: _|_(incompatible bounds >=11 and <11), ` +
`e8: _|_(incompatible bounds >11 and <=11), ` +
- `e9: _|_((>"a" & <1):unsupported op &((string)*, (number)*))}`,
+ `e9: _|_((>"a" & <1):unsupported op &(string, number))}`,
}, {
desc: "custom validators",
in: `
@@ -878,7 +878,7 @@
`t0: [<3>{a: 8}], ` +
`t1: [, ...int], ` +
`e0: _|_(([<4>{},<4>{}] & [<5>{}]):incompatible list lengths: cannot unify numbers 2 and 1), ` +
- `e1: _|_(([, ...int] & [, ...float]):incompatible list types: unsupported op &((int)*, (float)*): )` +
+ `e1: _|_(([, ...int] & [, ...float]):incompatible list types: unsupported op &(int, float): )` +
`}`,
}, {
// TODO: consider removing list arithmetic altogether. It is no longer
@@ -1296,8 +1296,8 @@
`b14: _|_(incompatible bounds >=6 and <=5), ` +
`c1: (int & >=1 & <=5), ` +
`c2: (<=5 & int & >=1), ` +
- `c3: _|_((string & >=1):unsupported op &((string)*, (number)*)), ` +
- `c4: _|_(((>=1 & <=5) & string):unsupported op &((number)*, (string)*)), ` +
+ `c3: _|_((string & >=1):unsupported op &(string, number)), ` +
+ `c4: _|_(((>=1 & <=5) & string):unsupported op &(number, string)), ` +
`s1: "e", ` +
`s2: "ee", ` +
`n1: (>=1 & <=2), ` +
@@ -1572,7 +1572,7 @@
in: `
a: 8000.9
a: 7080 | int`,
- out: `<0>{a: _|_((8000.9 & int):unsupported op &(float, (int)*))}`,
+ out: `<0>{a: _|_((8000.9 & int):unsupported op &(float, int))}`,
}, {
desc: "resolve all disjunctions",
in: `
diff --git a/cue/types_test.go b/cue/types_test.go
index dbabb38..895df3c 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -224,8 +224,8 @@
notInt: true,
}, {
value: "int",
- err: "non-concrete value (int)*",
- errU: "non-concrete value (int)*",
+ err: "non-concrete value int",
+ errU: "non-concrete value int",
notInt: true,
}, {
value: "_|_",
@@ -421,7 +421,7 @@
str: `Hello world!`,
}, {
value: `string`,
- err: "non-concrete value (string)*",
+ err: "non-concrete value string",
}}
for _, tc := range testCases {
t.Run(tc.value, func(t *testing.T) {
@@ -482,7 +482,7 @@
value: `null`,
}, {
value: `_`,
- err: "non-concrete value (_)*",
+ err: "non-concrete value _",
}}
for _, tc := range testCases {
t.Run(tc.value, func(t *testing.T) {
@@ -510,7 +510,7 @@
value: `false`,
}, {
value: `bool`,
- err: "non-concrete value (bool)*",
+ err: "non-concrete value bool",
}}
for _, tc := range testCases {
t.Run(tc.value, func(t *testing.T) {