...
1// TODO: merge the resulting files. This can only be done if off-by-one handling
2// is moved to expr handling too.
3//
4// For now this is better than panicking.
5
6-- x.cue --
7fieldAlias: simple: {
8 X="a-b": 4
9 foo: X
10
11 bar?: Y
12
13 Y="a-c": 5
14}
15
16valueAlias: merge: {
17 // Merge fields, rename alias to avoid conflict.
18 // TODO: merged values can still be simplified.
19 value: X={#value: X.b, b: 2}
20 value: Y={#value: Y.b, b: 2, v: X: 3}
21}
22
23valueAlias: selfRef: struct: {
24 a: b: X={#foo: X.b, b: 2}
25}
26
27valueAlias: selfRefValue: struct: {
28 // Note: this resolves to a cycle error, which is considered
29 // to be equal to "incomplete". As a result, in case of
30 // non-final evaluation, reference will remain. This is not
31 // an issue exclusive to value aliases, and falls within the
32 // range of what is acceptable for now.
33 // TODO: solve this issue.
34 a: X=or(X)
35}
36
37valueAlias: selfRefValue: pattern: {
38 // this triggers the verbatim "adt" path. Note that there
39 // is no need to rename the variable here as the expression
40 // was known to compile and is known to be correct.
41 a: [string]: X=or(X)
42}
43
44issue1308: {
45 let _xA = 1
46 sub: [{_A: _xA}]
47}
48
49// TODO: these could be merged into a single struct.
50issue2374: {
51 r=[string]: {z: 1, b: r | null}
52 a: {r: 0}
53}
54-- y.cue --
55fieldAlias: cross: {
56 baz: 3
57 X="d-2": E=[D="cue"]: C="foo\(baz)": {
58 name: "xx"
59 foo: C.name
60 bar: X
61 baz: D
62 qux: E
63 }
64}
65-- out/definition --
66fieldAlias: {
67 simple: {
68 X="a-b": 4
69 foo: X
70 bar?: Y
71 Y="a-c": 5
72 }
73 cross: {
74 baz: 3
75 X="d-2": {
76 E=[D="cue"]: {
77 C="foo3": {
78 name: "xx"
79 foo: C.name
80 bar: X
81 baz: D
82 qux: E
83 }
84 }
85 }
86 }
87}
88valueAlias: {
89 merge: {
90 // Merge fields, rename alias to avoid conflict.
91 // TODO: merged values can still be simplified.
92 value: X_1={
93 #value: X_1.b & X_1.b
94 b: 2
95 v: {
96 X: 3
97 }
98 }
99 }
100 selfRef: {
101 struct: {
102 a: {
103 b: X_2={
104 #foo: X_2.b
105 b: 2
106 }
107 }
108 }
109 }
110 selfRefValue: {
111 struct: {
112 // Note: this resolves to a cycle error, which is considered
113 // to be equal to "incomplete". As a result, in case of
114 // non-final evaluation, reference will remain. This is not
115 // an issue exclusive to value aliases, and falls within the
116 // range of what is acceptable for now.
117 // TODO: solve this issue.
118 a: X_3=or(X_3)
119 }
120 pattern: {
121 // this triggers the verbatim "adt" path. Note that there
122 // is no need to rename the variable here as the expression
123 // was known to compile and is known to be correct.
124 a: {
125 [string]: X=or(X)
126 }
127 }
128 }
129}
130issue1308: {
131 let _xA = 1
132 sub: [{
133 _A: _xA
134 }]
135}
136
137// TODO: these could be merged into a single struct.
138issue2374: {
139 r_1=[string]: {
140 z: 1
141 b: r_1 | null
142 }
143 a: {
144 r: 0
145 }
146}
147-- out/doc --
148[]
149[fieldAlias]
150[fieldAlias simple]
151[fieldAlias simple "a-b"]
152[fieldAlias simple foo]
153[fieldAlias simple bar]
154[fieldAlias simple "a-c"]
155[fieldAlias cross]
156[fieldAlias cross baz]
157[fieldAlias cross "d-2"]
158[valueAlias]
159[valueAlias merge]
160[valueAlias merge value]
161- Merge fields, rename alias to avoid conflict.
162TODO: merged values can still be simplified.
163
164[valueAlias merge value #value]
165[valueAlias merge value b]
166[valueAlias merge value v]
167[valueAlias merge value v X]
168[valueAlias selfRef]
169[valueAlias selfRef struct]
170[valueAlias selfRef struct a]
171[valueAlias selfRef struct a b]
172[valueAlias selfRef struct a b #foo]
173[valueAlias selfRef struct a b b]
174[valueAlias selfRefValue]
175[valueAlias selfRefValue struct]
176[valueAlias selfRefValue struct a]
177- Note: this resolves to a cycle error, which is considered
178to be equal to "incomplete". As a result, in case of
179non-final evaluation, reference will remain. This is not
180an issue exclusive to value aliases, and falls within the
181range of what is acceptable for now.
182TODO: solve this issue.
183
184[valueAlias selfRefValue pattern]
185[valueAlias selfRefValue pattern a]
186- this triggers the verbatim "adt" path. Note that there
187is no need to rename the variable here as the expression
188was known to compile and is known to be correct.
189
190[issue1308]
191[issue1308 _xA]
192[issue1308 sub]
193[issue1308 sub 0]
194[issue1308 sub 0 _A]
195[issue2374]
196- TODO: these could be merged into a single struct.
197
198[issue2374 a]
199[issue2374 a r]
200[issue2374 a z]
201[issue2374 a b]
202-- out/value --
203== Simplified
204{
205 fieldAlias: {
206 simple: {
207 "a-b": 4
208 foo: 4
209 "a-c": 5
210 }
211 cross: {
212 baz: 3
213 "d-2": {}
214 }
215 }
216 valueAlias: {
217 merge: {
218 // Merge fields, rename alias to avoid conflict.
219 // TODO: merged values can still be simplified.
220 value: {
221 b: 2
222 v: {
223 X: 3
224 }
225 }
226 }
227 selfRef: {
228 struct: {
229 a: {
230 b: {
231 b: 2
232 }
233 }
234 }
235 }
236 selfRefValue: {
237 struct: {
238 // Note: this resolves to a cycle error, which is considered
239 // to be equal to "incomplete". As a result, in case of
240 // non-final evaluation, reference will remain. This is not
241 // an issue exclusive to value aliases, and falls within the
242 // range of what is acceptable for now.
243 // TODO: solve this issue.
244 a: or(X)
245 }
246 pattern: {
247 // this triggers the verbatim "adt" path. Note that there
248 // is no need to rename the variable here as the expression
249 // was known to compile and is known to be correct.
250 a: {}
251 }
252 }
253 }
254 issue1308: {
255 sub: [{}]
256 }
257
258 // TODO: these could be merged into a single struct.
259 issue2374: {
260 a: {
261 r: 0
262 z: 1
263 b: null
264 }
265 }
266}
267== Raw
268{
269 fieldAlias: {
270 simple: {
271 "a-b": 4
272 foo: 4
273 bar?: 5
274 "a-c": 5
275 }
276 cross: {
277 baz: 3
278 "d-2": {}
279 }
280 }
281 valueAlias: {
282 merge: {
283 // Merge fields, rename alias to avoid conflict.
284 // TODO: merged values can still be simplified.
285 value: {
286 #value: 2
287 b: 2
288 v: {
289 X: 3
290 }
291 }
292 }
293 selfRef: {
294 struct: {
295 a: {
296 b: {
297 #foo: 2
298 b: 2
299 }
300 }
301 }
302 }
303 selfRefValue: {
304 struct: {
305 // Note: this resolves to a cycle error, which is considered
306 // to be equal to "incomplete". As a result, in case of
307 // non-final evaluation, reference will remain. This is not
308 // an issue exclusive to value aliases, and falls within the
309 // range of what is acceptable for now.
310 // TODO: solve this issue.
311 a: or(X)
312 }
313 pattern: {
314 // this triggers the verbatim "adt" path. Note that there
315 // is no need to rename the variable here as the expression
316 // was known to compile and is known to be correct.
317 a: {}
318 }
319 }
320 }
321 issue1308: {
322 sub: [{
323 _A: 1
324 }]
325 }
326
327 // TODO: these could be merged into a single struct.
328 issue2374: {
329 a: {
330 r: 0
331 z: 1
332 b: null
333 }
334 }
335}
336== Final
337{
338 fieldAlias: {
339 simple: {
340 "a-b": 4
341 foo: 4
342 "a-c": 5
343 }
344 cross: {
345 baz: 3
346 "d-2": {}
347 }
348 }
349 valueAlias: {
350 merge: {
351 value: {
352 b: 2
353 v: {
354 X: 3
355 }
356 }
357 }
358 selfRef: {
359 struct: {
360 a: {
361 b: {
362 b: 2
363 }
364 }
365 }
366 }
367 selfRefValue: {
368 struct: {
369 a: _|_ // cycle error
370 }
371 pattern: {
372 a: {}
373 }
374 }
375 }
376 issue1308: {
377 sub: [{}]
378 }
379 issue2374: {
380 a: {
381 r: 0
382 z: 1
383 b: null
384 }
385 }
386}
387== All
388{
389 fieldAlias: {
390 simple: {
391 "a-b": 4
392 foo: 4
393 bar?: 5
394 "a-c": 5
395 }
396 cross: {
397 baz: 3
398 "d-2": {}
399 }
400 }
401 valueAlias: {
402 merge: {
403 // Merge fields, rename alias to avoid conflict.
404 // TODO: merged values can still be simplified.
405 value: {
406 #value: 2
407 b: 2
408 v: {
409 X: 3
410 }
411 }
412 }
413 selfRef: {
414 struct: {
415 a: {
416 b: {
417 #foo: 2
418 b: 2
419 }
420 }
421 }
422 }
423 selfRefValue: {
424 struct: {
425 // Note: this resolves to a cycle error, which is considered
426 // to be equal to "incomplete". As a result, in case of
427 // non-final evaluation, reference will remain. This is not
428 // an issue exclusive to value aliases, and falls within the
429 // range of what is acceptable for now.
430 // TODO: solve this issue.
431 a: or(X)
432 }
433 pattern: {
434 // this triggers the verbatim "adt" path. Note that there
435 // is no need to rename the variable here as the expression
436 // was known to compile and is known to be correct.
437 a: {}
438 }
439 }
440 }
441 issue1308: {
442 sub: [{
443 _A: 1
444 }]
445 }
446
447 // TODO: these could be merged into a single struct.
448 issue2374: {
449 a: {
450 r: 0
451 z: 1
452 b: null
453 }
454 }
455}
456== Eval
457{
458 fieldAlias: {
459 simple: {
460 "a-b": 4
461 foo: 4
462 bar?: 5
463 "a-c": 5
464 }
465 cross: {
466 baz: 3
467 "d-2": {}
468 }
469 }
470 valueAlias: {
471 merge: {
472 value: {
473 #value: 2
474 b: 2
475 v: {
476 X: 3
477 }
478 }
479 }
480 selfRef: {
481 struct: {
482 a: {
483 b: {
484 #foo: 2
485 b: 2
486 }
487 }
488 }
489 }
490 selfRefValue: {
491 struct: {
492 a: or(X)
493 }
494 pattern: {
495 a: {}
496 }
497 }
498 }
499 issue1308: {
500 sub: [{}]
501 }
502 issue2374: {
503 a: {
504 r: 0
505 z: 1
506 b: null
507 }
508 }
509}
View as plain text