cue: disallow string and bytes indexing and slicing

According to spec update.

Allowing these operations hurts interoperability.
Users can now use builtin package functions instead.

Note that string slicing was already not
implemented according to spec, and thus
broken.

Change-Id: I5100f65b294c8bc4383f6019c5600834dc9221a9
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2920
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/eval.go b/cue/eval.go
index 0a36b21..bfb2207 100644
--- a/cue/eval.go
+++ b/cue/eval.go
@@ -91,7 +91,7 @@
 	const msgType = "invalid operation: %[5]s (type %[3]s does not support indexing)"
 	const msgIndexType = "invalid %[5]s index %[1]s (type %[3]s)"
 
-	val := e.eval(x.x, listKind|structKind|stringKind|bytesKind, msgType, x)
+	val := e.eval(x.x, listKind|structKind, msgType, x)
 	k := val.kind()
 	index := e.eval(x.index, stringKind|intKind, msgIndexType, k)
 
@@ -136,7 +136,7 @@
 	e := newEval(ctx, true)
 	const msgType = "cannot slice %[2]s (type %[3]s)"
 	const msgInvalidIndex = "invalid slice index %[1]s (type %[3]s)"
-	val := e.eval(x.x, listKind|stringKind, msgType)
+	val := e.eval(x.x, listKind, msgType)
 	lo := e.evalAllowNil(x.lo, intKind, msgInvalidIndex)
 	hi := e.evalAllowNil(x.hi, intKind, msgInvalidIndex)
 	var low, high *numLit
diff --git a/cue/resolve_test.go b/cue/resolve_test.go
index 736bbc3..84d63a7 100644
--- a/cue/resolve_test.go
+++ b/cue/resolve_test.go
@@ -787,18 +787,20 @@
 			e6: (*[]|{})[1]
 		`,
 		out: `<0>{a: 2, b: "bar", c: _|_("3":invalid list index "3" (type string)), l: [], d: _|_([]:index 0 out of bounds), e1: _|_("":invalid list index "" (type string)), e2: _|_(2:invalid operation: 2[2] (type int does not support indexing)), e3: _|_(true:invalid list index true (type bool)), e4: _|_([1,2,3]:index 3 out of bounds), e5: _|_(-1:invalid list index -1 (index must be non-negative)), e6: _|_([]:index 1 out of bounds)}`,
-	}, {
-		desc: "string index",
-		in: `
-			a0: "abc"[0]
-			a1: "abc"[1]
-			a2: "abc"[2]
-			a3: "abc"[3]
-			a4: "abc"[-1]
+		// }, {
+		// NOTE: string indexing no longer supported.
+		// Keeping it around until this is no longer an experiment.
+		// 	desc: "string index",
+		// 	in: `
+		// 		a0: "abc"[0]
+		// 		a1: "abc"[1]
+		// 		a2: "abc"[2]
+		// 		a3: "abc"[3]
+		// 		a4: "abc"[-1]
 
-			b: "zoëven"[2]
-		`,
-		out: `<0>{a0: "a", a1: "b", a2: "c", a3: _|_("abc":index 3 out of bounds), a4: _|_(-1:invalid string index -1 (index must be non-negative)), b: "ë"}`,
+		// 		b: "zoëven"[2]
+		// 	`,
+		// 	out: `<0>{a0: "a", a1: "b", a2: "c", a3: _|_("abc":index 3 out of bounds), a4: _|_(-1:invalid string index -1 (index must be non-negative)), b: "ë"}`,
 	}, {
 		desc: "disjunctions of lists",
 		in: `
@@ -823,25 +825,27 @@
 
 		`,
 		out: `<0>{a: [], b: [], e1: _|_(1:slice bounds out of range), e2: _|_([0]:negative slice index), e3: _|_([0]:invalid slice index: 1 > 0), e4: _|_(2:slice bounds out of range), e5: _|_(4:cannot slice 4 (type int)), e6: _|_("":invalid slice index "" (type string)), e7: _|_("9":invalid slice index "9" (type string))}`,
-	}, {
-		desc: "string slice",
-		in: `
-			a0: ""[0:0]
-			a1: ""[:]
-			a2: ""[0:]
-			a3: ""[:0]
-			b0: "abc"[0:0]
-			b1: "abc"[0:1]
-			b2: "abc"[0:2]
-			b3: "abc"[0:3]
-			b4: "abc"[3:3]
-			b5: "abc"[1:]
-			b6: "abc"[:2]
+		// }, {
+		// NOTE: string indexing no longer supported.
+		// Keeping it around until this is no longer an experiment.
+		// 	desc: "string slice",
+		// 	in: `
+		// 		a0: ""[0:0]
+		// 		a1: ""[:]
+		// 		a2: ""[0:]
+		// 		a3: ""[:0]
+		// 		b0: "abc"[0:0]
+		// 		b1: "abc"[0:1]
+		// 		b2: "abc"[0:2]
+		// 		b3: "abc"[0:3]
+		// 		b4: "abc"[3:3]
+		// 		b5: "abc"[1:]
+		// 		b6: "abc"[:2]
 
-			// TODO: supported extended graphemes, instead of just runes.
-			u: "Spaß"[3:4]
-		`,
-		out: `<0>{a0: "", a1: "", a2: "", a3: "", b0: "", b1: "a", b2: "ab", b3: "abc", b4: "", b5: "bc", b6: "ab", u: "ß"}`,
+		// 		// TODO: supported extended graphemes, instead of just runes.
+		// 		u: "Spaß"[3:4]
+		// 	`,
+		// 	out: `<0>{a0: "", a1: "", a2: "", a3: "", b0: "", b1: "a", b2: "ab", b3: "abc", b4: "", b5: "bc", b6: "ab", u: "ß"}`,
 	}, {
 		desc: "list types",
 		in: `