You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 <[email protected]>
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)}`,
790
-
}, {
791
-
desc: "string index",
792
-
in: `
793
-
a0: "abc"[0]
794
-
a1: "abc"[1]
795
-
a2: "abc"[2]
796
-
a3: "abc"[3]
797
-
a4: "abc"[-1]
798
-
799
-
b: "zoëven"[2]
800
-
`,
801
-
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: "ë"}`,
790
+
// }, {
791
+
// NOTE: string indexing no longer supported.
792
+
// Keeping it around until this is no longer an experiment.
793
+
// desc: "string index",
794
+
// in: `
795
+
// a0: "abc"[0]
796
+
// a1: "abc"[1]
797
+
// a2: "abc"[2]
798
+
// a3: "abc"[3]
799
+
// a4: "abc"[-1]
800
+
801
+
// b: "zoëven"[2]
802
+
// `,
803
+
// 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: "ë"}`,
0 commit comments