Skip to content

Commit f93b6b9

Browse files
committed
pkg/list: add regression test for issue 2594
This ordering issue, where swapping the order of two fields in #Def caused an error to appear or disappear in evalv2, is fixed in evalv3. Closes #2594. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I4c56a719491311bf009f80988882d12ff1f01b1d Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214570 Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent aacdc3b commit f93b6b9

File tree

1 file changed

+97
-7
lines changed

1 file changed

+97
-7
lines changed

pkg/list/testdata/issues.txtar

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ issue3541: {
5454
val.num + val.test
5555
}])
5656
}
57+
58+
issue2594: sumFirst: {
59+
#Def: {
60+
number & list.Sum(#In)
61+
#In: [...number]
62+
}
63+
64+
x!: 6
65+
x: #Def & {_
66+
#In: [1, 2, 3]
67+
}
68+
}
69+
issue2594: sumSecond: {
70+
#Def: {
71+
#In: [...number]
72+
number & list.Sum(#In)
73+
}
74+
75+
x!: 6
76+
x: #Def & {_
77+
#In: [1, 2, 3]
78+
}
79+
}
5780
-- out/list-v3 --
5881
Errors:
5982
0: invalid operands 2 and {num:6} to '+' (type int and struct):
@@ -85,30 +108,78 @@ issue1404: {
85108
sum: 1
86109
}
87110
issue3541: _|_ // 0: invalid operands 2 and {num:6} to '+' (type int and struct)
111+
issue2594: {
112+
sumFirst: {
113+
#Def: {
114+
0
115+
#In: [...number]
116+
}
117+
x: {
118+
6
119+
#In: [1, 2, 3]
120+
}
121+
}
122+
sumSecond: {
123+
#Def: {
124+
0
125+
#In: [...number]
126+
}
127+
x: {
128+
6
129+
#In: [1, 2, 3]
130+
}
131+
}
132+
}
88133
-- diff/-out/list-v3<==>+out/list --
89134
diff old new
90135
--- old
91136
+++ new
92-
@@ -1,3 +1,10 @@
93-
+Errors:
137+
@@ -1,9 +1,8 @@
138+
Errors:
139+
-issue2594.sumSecond.x: conflicting values 0 and 6:
140+
- ./in.cue:71:3
141+
- ./in.cue:71:12
142+
- ./in.cue:74:6
143+
- ./in.cue:75:6
94144
+0: invalid operands 2 and {num:6} to '+' (type int and struct):
95145
+ ./in.cue:53:3
96146
+ ./in.cue:35:9
97147
+ ./in.cue:36:10
98-
+
99-
+Result:
148+
149+
Result:
100150
issue563: {
101-
#MyDef: {
102-
name: string
103-
@@ -20,4 +27,4 @@
151+
@@ -28,7 +27,7 @@
104152
a: *1 | 2
105153
sum: 1
106154
}
107155
-issue3541: {}
108156
+issue3541: _|_ // 0: invalid operands 2 and {num:6} to '+' (type int and struct)
157+
issue2594: {
158+
sumFirst: {
159+
#Def: {
160+
@@ -45,6 +44,9 @@
161+
0
162+
#In: [...number]
163+
}
164+
- x: _|_ // issue2594.sumSecond.x: conflicting values 0 and 6
165+
+ x: {
166+
+ 6
167+
+ #In: [1, 2, 3]
168+
+ }
169+
}
170+
}
109171
-- diff/explanation --
110172
issue3541: evalv3 correctly spots an invalid operand error which evalv2 drops on the floor.
173+
issue2594: evalv3 fixes an ordering issue present in evalv2.
111174
-- out/list --
175+
Errors:
176+
issue2594.sumSecond.x: conflicting values 0 and 6:
177+
./in.cue:71:3
178+
./in.cue:71:12
179+
./in.cue:74:6
180+
./in.cue:75:6
181+
182+
Result:
112183
issue563: {
113184
#MyDef: {
114185
name: string
@@ -132,3 +203,22 @@ issue1404: {
132203
sum: 1
133204
}
134205
issue3541: {}
206+
issue2594: {
207+
sumFirst: {
208+
#Def: {
209+
0
210+
#In: [...number]
211+
}
212+
x: {
213+
6
214+
#In: [1, 2, 3]
215+
}
216+
}
217+
sumSecond: {
218+
#Def: {
219+
0
220+
#In: [...number]
221+
}
222+
x: _|_ // issue2594.sumSecond.x: conflicting values 0 and 6
223+
}
224+
}

0 commit comments

Comments
 (0)