Skip to content

Commit 4c7ee01

Browse files
committed
internal/core/adt: add test for dropped field issue
Currently, inline struct were reapproriated by linking them into the destination struct by setting the parent and label. However, labels are used to look up fields. This resulted in fields being dropped. This test exposes that. Issue #3601 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Icdfd3e9edac458ffb08a3759a2fd350e3cfdf363 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205231 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
1 parent dc1ef63 commit 4c7ee01

File tree

1 file changed

+91
-9
lines changed

1 file changed

+91
-9
lines changed

cue/testdata/eval/sharing.txtar

+91-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ issue3062: ok1: {
1010
A: "a"
1111
}
1212

13+
issue3601: ok1: {
14+
Y: (X & __no_sharing).a
15+
X: a: b: a.b
16+
out: Y & __no_sharing
17+
}
18+
1319
// Test debug facilities to turn of sharing.
1420
debug: {
1521
sharingOn: {
@@ -32,15 +38,15 @@ debug: {
3238
}
3339
}
3440
-- out/eval/stats --
35-
Leaks: 0
36-
Freed: 33
37-
Reused: 26
38-
Allocs: 7
39-
Retain: 7
41+
Leaks: 2
42+
Freed: 40
43+
Reused: 33
44+
Allocs: 9
45+
Retain: 10
4046

41-
Unifications: 33
42-
Conjuncts: 49
43-
Disjuncts: 38
47+
Unifications: 42
48+
Conjuncts: 64
49+
Disjuncts: 48
4450
-- out/evalalpha --
4551
(struct){
4652
issue3062: (struct){
@@ -58,6 +64,24 @@ Disjuncts: 38
5864
A: (string){ "a" }
5965
}
6066
}
67+
issue3601: (struct){
68+
ok1: (struct){
69+
Y: (struct){
70+
b: (_){ _ }
71+
}
72+
X: (struct){
73+
a: (struct){
74+
b: (_){ _ }
75+
}
76+
}
77+
out: (struct){
78+
b: (_|_){
79+
// [incomplete] issue3601.ok1.out.b: undefined field: a:
80+
// ./in.cue:12:11
81+
}
82+
}
83+
}
84+
}
6185
debug: (struct){
6286
sharingOn: (struct){
6387
a: ~(debug.sharingOn.b)
@@ -108,12 +132,42 @@ diff old new
108132
issue3062: (struct){
109133
ok1: (struct){
110134
#S: (string){ "a" }
111-
@@ -19,42 +14,32 @@
135+
@@ -19,12 +14,10 @@
112136
A: (string){ "a" }
113137
}
114138
}
139+
- issue3601: (_|_){
140+
- // [eval]
141+
- ok1: (_|_){
142+
- // [eval]
143+
- Y: (_|_){
144+
- // [eval] no sharing
145+
+ issue3601: (struct){
146+
+ ok1: (struct){
147+
+ Y: (struct){
148+
+ b: (_){ _ }
149+
}
150+
X: (struct){
151+
a: (struct){
152+
@@ -31,47 +24,40 @@
153+
b: (_){ _ }
154+
}
155+
}
156+
- out: (_|_){
157+
- // [eval] no sharing
158+
- }
159+
- }
160+
- }
115161
- debug: (_|_){
116162
- // [eval]
163+
+ out: (struct){
164+
+ b: (_|_){
165+
+ // [incomplete] issue3601.ok1.out.b: undefined field: a:
166+
+ // ./in.cue:12:11
167+
+ }
168+
+ }
169+
+ }
170+
+ }
117171
+ debug: (struct){
118172
sharingOn: (struct){
119173
- a: (struct){
@@ -194,6 +248,23 @@ Result:
194248
A: (string){ "a" }
195249
}
196250
}
251+
issue3601: (_|_){
252+
// [eval]
253+
ok1: (_|_){
254+
// [eval]
255+
Y: (_|_){
256+
// [eval] no sharing
257+
}
258+
X: (struct){
259+
a: (struct){
260+
b: (_){ _ }
261+
}
262+
}
263+
out: (_|_){
264+
// [eval] no sharing
265+
}
266+
}
267+
}
197268
debug: (_|_){
198269
// [eval]
199270
sharingOn: (struct){
@@ -256,6 +327,17 @@ Result:
256327
A: "a"
257328
}
258329
}
330+
issue3601: {
331+
ok1: {
332+
Y: (〈0;X〉 & _|_(no sharing)).a
333+
X: {
334+
a: {
335+
b: 〈1;a〉.b
336+
}
337+
}
338+
out: (〈0;Y〉 & _|_(no sharing))
339+
}
340+
}
259341
debug: {
260342
sharingOn: {
261343
a: 〈0;b〉

0 commit comments

Comments
 (0)