Skip to content

Commit

Permalink
all: remove support for list arithmetic
Browse files Browse the repository at this point in the history
And adjust or remove tests that use list arithmetic.

This has a knock-on effect that in cuego, tags which indicate list
length are no longer supported. E.g. `cue:"3*[int|*1]"`. We cannot
automatically fix these use cases, but we also don't expect this change
to cause breakages as list arithmetic has been undocumented for years
and cuego tags tend to be simple expressions.

Some of the fixes to tests expose different bugs/limitations in evalv2,
though work fine with evalv3, so it's possible evalv2 users will
experience more bugs after this change. But these are only in very odd
semi-cyclic scenarios.

Fixes #2237

Signed-off-by: Matthew Sackman <matthew@cue.works>
Change-Id: I39fe190ac2131f60734f91485474e9c94758367f
Dispatch-Trailer: {"type":"trybot","CL":1200221,"patchset":5,"ref":"refs/changes/21/1200221/5","targetBranch":"master"}
  • Loading branch information
cuematthew authored and cueckoo committed Aug 29, 2024
1 parent 540f282 commit 4ff0079
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 1,356 deletions.
108 changes: 0 additions & 108 deletions cue/testdata/basicrewrite/011_list_arithmetic.txtar

This file was deleted.

29 changes: 17 additions & 12 deletions cue/testdata/comprehensions/issue843.txtar
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
-- in.cue --
package main

import "list"

#d1: {
as: [...string]

#c: [
#f1 & {
"as": ["go"] + as
"as": list.Concat([["go"], as])
},
]
}
Expand Down Expand Up @@ -41,15 +43,15 @@ package main
from: #c1
}
-- out/eval/stats --
Leaks: 9
Freed: 55
Reused: 41
Allocs: 23
Retain: 14
Leaks: 0
Freed: 85
Reused: 70
Allocs: 15
Retain: 7

Unifications: 52
Conjuncts: 120
Disjuncts: 66
Unifications: 65
Conjuncts: 159
Disjuncts: 92
-- out/evalalpha --
(struct){
#d1: (#struct){
Expand Down Expand Up @@ -239,9 +241,12 @@ Reordering
]
#c: [
(〈2;#f1〉 & {
as: ([
"go",
] + 〈2;as〉)
as: 〈import;list〉.Concat([
[
"go",
],
〈3;as〉,
])
}),
]
}
Expand Down
113 changes: 72 additions & 41 deletions cue/testdata/cycle/chain.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ chain: t2: p1: {
X: 1

// Reference X through x.x0 before X is inserted.
for v in [0, X] + [] {
for v in list.Concat([[0, X], []]) {
x: "x\(v)": {}
}

Expand All @@ -41,7 +41,7 @@ chain: t2: p1: {

chain: t2: p2: {
// Reference X through x.x0 before X is inserted.
for v in [0, X] + [] {
for v in list.Concat([[0, X], []]) {
x: "x\(v)": {}
}

Expand Down Expand Up @@ -208,14 +208,14 @@ issue2052: full: {
d: #Depth & {#in: tree}
}
-- out/evalalpha/stats --
Leaks: 19997
Leaks: 19999
Freed: 1462
Reused: 1461
Allocs: 19998
Allocs: 20000
Retain: 0

Unifications: 7504
Conjuncts: 107530
Unifications: 7506
Conjuncts: 107540
Disjuncts: 13655
-- out/evalalpha --
Errors:
Expand Down Expand Up @@ -720,22 +720,22 @@ diff old new
--- old
+++ new
@@ -1,9 +1,9 @@
-Leaks: 70
-Freed: 1815
-Reused: 1801
-Allocs: 84
-Retain: 185
+Leaks: 19997
-Leaks: 56
-Freed: 1830
-Reused: 1816
-Allocs: 70
-Retain: 169
+Leaks: 19999
+Freed: 1462
+Reused: 1461
+Allocs: 19998
+Allocs: 20000
+Retain: 0

-Unifications: 800
-Conjuncts: 3175
-Disjuncts: 1974
+Unifications: 7504
+Conjuncts: 107530
-Unifications: 801
-Conjuncts: 3177
-Disjuncts: 1979
+Unifications: 7506
+Conjuncts: 107540
+Disjuncts: 13655
-- diff/-out/evalalpha<==>+out/eval --
diff old new
Expand All @@ -755,7 +755,28 @@ diff old new
chain: (struct){
t1: (struct){
#maxiter: (int){ 2 }
@@ -47,148 +55,148 @@
@@ -27,15 +35,11 @@
}
}
}
- p2: (_|_){
- // [incomplete] 1: invalid interpolation: cycle error referencing X:
- // ./in.cue:44:6
- // ./in.cue:43:28
- x: (_|_){
- // [incomplete] 1: invalid interpolation: cycle error referencing X:
- // ./in.cue:44:6
- // ./in.cue:43:28
- x0: (struct){
+ p2: (struct){
+ x: (struct){
+ x0: (struct){
+ }
+ x1: (struct){
}
}
X: (int){ 1 }
@@ -51,148 +55,148 @@
}
}
}
Expand Down Expand Up @@ -1041,7 +1062,7 @@ diff old new
#maxiter: (int){ |(*(int){ 4 }, (int){ &(>=0, int) }) }
#funcFactory: (#struct){
#next: (_){ _ }
@@ -335,49 +343,7 @@
@@ -339,49 +343,7 @@
}
cow: (string){ "moo" }
}
Expand Down Expand Up @@ -1092,7 +1113,7 @@ diff old new
#in: (#struct){
a: (#struct){
foo: (string){ "bar" }
@@ -389,6 +355,142 @@
@@ -393,6 +355,142 @@
}
cow: (string){ "moo" }
}
Expand Down Expand Up @@ -1236,15 +1257,15 @@ diff old new
}
}
-- out/eval/stats --
Leaks: 70
Freed: 1815
Reused: 1801
Allocs: 84
Retain: 185
Leaks: 56
Freed: 1830
Reused: 1816
Allocs: 70
Retain: 169

Unifications: 800
Conjuncts: 3175
Disjuncts: 1974
Unifications: 801
Conjuncts: 3177
Disjuncts: 1979
-- diff/todo/p1 --
issue2052.*.#Depth: incorrect error message:
"adding field #basic not allowed as field set was already referenced"
Expand Down Expand Up @@ -1280,12 +1301,16 @@ issue2052.full.d: "cannot add field #maxiter: was already used"
}
}
}
p2: (struct){
x: (struct){
p2: (_|_){
// [incomplete] 1: invalid interpolation: cycle error referencing X:
// ./in.cue:44:6
// ./in.cue:43:28
x: (_|_){
// [incomplete] 1: invalid interpolation: cycle error referencing X:
// ./in.cue:44:6
// ./in.cue:43:28
x0: (struct){
}
x1: (struct){
}
}
X: (int){ 1 }
}
Expand Down Expand Up @@ -1676,10 +1701,13 @@ issue2052.full.d: "cannot add field #maxiter: was already used"
t2: {
p1: {
X: 1
for _, v in ([
0,
〈1;X〉,
] + []) {
for _, v in 〈import;list〉.Concat([
[
0,
〈2;X〉,
],
[],
]) {
x: {
"x\(〈2;v〉)": {}
}
Expand All @@ -1692,10 +1720,13 @@ issue2052.full.d: "cannot add field #maxiter: was already used"
chain: {
t2: {
p2: {
for _, v in ([
0,
〈1;X〉,
] + []) {
for _, v in 〈import;list〉.Concat([
[
0,
〈2;X〉,
],
[],
]) {
x: {
"x\(〈2;v〉)": {}
}
Expand Down
Loading

0 comments on commit 4ff0079

Please sign in to comment.