...
1-- in.cue --
2a: close({
3 a: b: int
4})
5
6b: a & {x: int} // err
7c: a & {a: c: int} // okay (non-recursive close)
8
9inDisjunctions: {
10 x: [string]: #Def
11 #Def: [string]: {
12 a: b: true
13 let X = a
14 close({uint: a: b: X.b}) | close({string: a: b: true})
15 }
16 x: socket: string: {}
17 x: syslog: x.socket
18 x: syslog: xxx: {}
19}
20
21issue642: {
22 test: close({
23 a: _
24 b: x: _
25 } & {
26 [string]: y: _
27 })
28
29 test: a: x: _
30 test: b: x: _
31}
32
33// Issue 642
34withSubfields: {
35 test: close({
36 a: _
37 b: x: _
38 [string]: y: _
39 })
40
41 test: a: x: _
42 test: b: x: _
43}
44-- out/eval/stats --
45Leaks: 39
46Freed: 160
47Reused: 150
48Allocs: 49
49Retain: 40
50
51Unifications: 185
52Conjuncts: 365
53Disjuncts: 190
54-- out/eval --
55Errors:
56b.x: field not allowed:
57 ./in.cue:1:10
58 ./in.cue:5:4
59 ./in.cue:5:9
60
61Result:
62(_|_){
63 // [eval]
64 a: (#struct){
65 a: (struct){
66 b: (int){ int }
67 }
68 }
69 b: (_|_){
70 // [eval]
71 a: (struct){
72 b: (int){ int }
73 }
74 x: (_|_){
75 // [eval] b.x: field not allowed:
76 // ./in.cue:1:10
77 // ./in.cue:5:4
78 // ./in.cue:5:9
79 }
80 }
81 c: (#struct){
82 a: (struct){
83 b: (int){ int }
84 c: (int){ int }
85 }
86 }
87 inDisjunctions: (struct){
88 x: (struct){
89 socket: (#struct){
90 string: (#struct){ |((#struct){
91 a: (#struct){
92 b: (bool){ true }
93 }
94 let X#1 = (#struct){
95 b: (bool){ true }
96 }
97 uint: (#struct){
98 a: (#struct){
99 b: (bool){ true }
100 }
101 }
102 }, (#struct){
103 a: (#struct){
104 b: (bool){ true }
105 }
106 let X#1 = (#struct){
107 b: (bool){ true }
108 }
109 string: (#struct){
110 a: (#struct){
111 b: (bool){ true }
112 }
113 }
114 }) }
115 }
116 syslog: (#struct){
117 string: (#struct){ |((#struct){
118 a: (#struct){
119 b: (bool){ true }
120 }
121 let X#1multi = 〈0;a〉
122 uint: (#struct){
123 a: (#struct){
124 b: (bool){ true }
125 }
126 }
127 }, (#struct){
128 a: (#struct){
129 b: (bool){ true }
130 }
131 let X#1multi = 〈0;a〉
132 string: (#struct){
133 a: (#struct){
134 b: (bool){ true }
135 }
136 }
137 }) }
138 xxx: (#struct){ |((#struct){
139 a: (#struct){
140 b: (bool){ true }
141 }
142 let X#1multi = 〈0;a〉
143 uint: (#struct){
144 a: (#struct){
145 b: (bool){ true }
146 }
147 }
148 }, (#struct){
149 a: (#struct){
150 b: (bool){ true }
151 }
152 let X#1multi = 〈0;a〉
153 string: (#struct){
154 a: (#struct){
155 b: (bool){ true }
156 }
157 }
158 }) }
159 }
160 }
161 #Def: (#struct){
162 }
163 }
164 issue642: (struct){
165 test: (#struct){
166 a: (struct){
167 x: (_){ _ }
168 y: (_){ _ }
169 }
170 b: (struct){
171 x: (_){ _ }
172 y: (_){ _ }
173 }
174 }
175 }
176 withSubfields: (struct){
177 test: (#struct){
178 a: (struct){
179 x: (_){ _ }
180 y: (_){ _ }
181 }
182 b: (struct){
183 x: (_){ _ }
184 y: (_){ _ }
185 }
186 }
187 }
188}
189-- out/compile --
190--- in.cue
191{
192 a: close({
193 a: {
194 b: int
195 }
196 })
197 b: (〈0;a〉 & {
198 x: int
199 })
200 c: (〈0;a〉 & {
201 a: {
202 c: int
203 }
204 })
205 inDisjunctions: {
206 x: {
207 [string]: 〈1;#Def〉
208 }
209 #Def: {
210 [string]: {
211 a: {
212 b: true
213 }
214 let X#1 = 〈0;a〉
215 (close({
216 uint: {
217 a: {
218 b: 〈3;let X#1〉.b
219 }
220 }
221 })|close({
222 string: {
223 a: {
224 b: true
225 }
226 }
227 }))
228 }
229 }
230 x: {
231 socket: {
232 string: {}
233 }
234 }
235 x: {
236 syslog: 〈1;x〉.socket
237 }
238 x: {
239 syslog: {
240 xxx: {}
241 }
242 }
243 }
244 issue642: {
245 test: close(({
246 a: _
247 b: {
248 x: _
249 }
250 } & {
251 [string]: {
252 y: _
253 }
254 }))
255 test: {
256 a: {
257 x: _
258 }
259 }
260 test: {
261 b: {
262 x: _
263 }
264 }
265 }
266 withSubfields: {
267 test: close({
268 a: _
269 b: {
270 x: _
271 }
272 [string]: {
273 y: _
274 }
275 })
276 test: {
277 a: {
278 x: _
279 }
280 }
281 test: {
282 b: {
283 x: _
284 }
285 }
286 }
287}
View as plain text