File: 052_resolved_self-reference_cycles_with_disjunction_with_defaults.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (293 lines) | stat: -rw-r--r-- 7,599 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#name: resolved self-reference cycles with disjunction with defaults
#evalPartial
-- in.cue --
// The disjunction in xa could be resolved, but as disjunctions
// are not resolved for expression, it remains unresolved.
xa1: (xa2 & 8) | *(xa4 & 9)
xa2: xa3 + 2
xa3: 6 & xa1-2
xa4: xa2 + 2

xb1: *(xb2 & 8) | (xb4 & 9)
xb2: xb3 + 2
xb3: *(6 & (xb1 - 2)) | (xb4 & 9)
xb4: xb2 + 2

// Another variant with more disjunctions. xc1 remains with two
// possibilities. Technically, only the first value is valid.
// However, to fully determine that, all options of the remaining
// disjunction will have to be evaluated algebraically, which is
// not done.
xc1: *(xc2 & 8) | (xc4 & 9) | (xc5 & 9)
xc2: xc3 + 2
xc3: 6 & xc1-2
xc4: xc2 + 1
xc5: xc2 + 2

// The above is resolved by setting xd1 explicitly.
xd1: *(xd2 & 8) | xd4 & 9 | xd5 & 9
xd2: xd3 + 2
xd3: 6 & xd1-2
xd4: xd2 + 1
xd5: xd2 + 2

// The above is resolved by setting xd1 explicitly to the wrong
// value, resulting in an error.
xe1: *(xe2 & 8) | xe4 & 9 | xe5 & 9
xe2: xe3 + 2
xe3: 6 & xe1-2
xe4: xe2 + 1
xe5: xe2 + 2
xe1: 9

z1: *(z2 + 1) | z3+5
z2: z3 + 2
z3: z1 - 3
z3: 8
-- out/def --
// The disjunction in xa could be resolved, but as disjunctions
// are not resolved for expression, it remains unresolved.
xa1: 8
xa2: 8
xa4: 10
xa3: 6

// As xb3 is a disjunction, xb2 cannot be resolved and evaluating
// the cycle completely is broken. However, it is not an error
// as the user might still resolve the disjunction.
xb1: 8
xb2: 8
xb4: 10
xb3: 6

// Another variant with more disjunctions. xc1 remains with two
// possibilities. Technically, only the first value is valid.
// However, to fully determine that, all options of the remaining
// disjunction will have to be evaluated algebraically, which is
// not done.
xc1: *8 | 9 | _|_ // conflicting values 10 and 9
xc2: 8
xc4: 9
xc5: 10
xc3: 6

// The above is resolved by setting xd1 explicitly.
xd1: *8 | 9 | _|_ // conflicting values 10 and 9
xd2: 8
xd4: 9
xd5: 10
xd3: 6

// The above is resolved by setting xd1 explicitly to the wrong
// value, resulting in an error.
xe1: _|_ // conflicting values 6 and 7
xe2: _|_ // conflicting values 6 and 7
xe4: _|_ // conflicting values 6 and 7
xe5: _|_ // conflicting values 6 and 7
xe3: _|_ // conflicting values 6 and 7
z1:  *11 | 13
z2:  10
z3:  8
-- out/legacy-debug --
<0>{xa1: 8, xa2: 8, xa4: 10, xa3: 6, xb1: 8, xb2: 8, xb4: 10, xb3: 6, xc1: (*8 | 9), xc2: 8, xc4: 9, xc5: 10, xc3: 6, xd1: (*8 | 9), xd2: 8, xd4: 9, xd5: 10, xd3: 6, xe1: _|_((6 & 7):conflicting values 6 and 7), xe2: _|_((6 & 7):conflicting values 6 and 7), xe4: _|_((6 & 7):conflicting values 6 and 7), xe5: _|_((6 & 7):conflicting values 6 and 7), xe3: _|_((6 & 7):conflicting values 6 and 7), z1: (*11 | 13), z2: 10, z3: 8}
-- out/compile --
--- in.cue
{
  xa1: ((〈0;xa2〉 & 8)|*(〈0;xa4〉 & 9))
  xa2: (〈0;xa3〉 + 2)
  xa3: (6 & (〈0;xa1〉 - 2))
  xa4: (〈0;xa2〉 + 2)
  xb1: (*(〈0;xb2〉 & 8)|(〈0;xb4〉 & 9))
  xb2: (〈0;xb3〉 + 2)
  xb3: (*(6 & (〈0;xb1〉 - 2))|(〈0;xb4〉 & 9))
  xb4: (〈0;xb2〉 + 2)
  xc1: (*(〈0;xc2〉 & 8)|(〈0;xc4〉 & 9)|(〈0;xc5〉 & 9))
  xc2: (〈0;xc3〉 + 2)
  xc3: (6 & (〈0;xc1〉 - 2))
  xc4: (〈0;xc2〉 + 1)
  xc5: (〈0;xc2〉 + 2)
  xd1: (*(〈0;xd2〉 & 8)|(〈0;xd4〉 & 9)|(〈0;xd5〉 & 9))
  xd2: (〈0;xd3〉 + 2)
  xd3: (6 & (〈0;xd1〉 - 2))
  xd4: (〈0;xd2〉 + 1)
  xd5: (〈0;xd2〉 + 2)
  xe1: (*(〈0;xe2〉 & 8)|(〈0;xe4〉 & 9)|(〈0;xe5〉 & 9))
  xe2: (〈0;xe3〉 + 2)
  xe3: (6 & (〈0;xe1〉 - 2))
  xe4: (〈0;xe2〉 + 1)
  xe5: (〈0;xe2〉 + 2)
  xe1: 9
  z1: (*(〈0;z2〉 + 1)|(〈0;z3〉 + 5))
  z2: (〈0;z3〉 + 2)
  z3: (〈0;z1〉 - 3)
  z3: 8
}
-- out/eval/stats --
Leaks:  0
Freed:  44
Reused: 36
Allocs: 8
Retain: 25

Unifications: 27
Conjuncts:    82
Disjuncts:    58
-- out/evalalpha --
Errors:
xe3: conflicting values 7 and 6:
    ./in.cue:35:6
    ./in.cue:35:10

Result:
(_|_){
  // [eval]
  xa1: (int){ 8 }
  xa2: (int){ 8 }
  xa3: (int){ 6 }
  xa4: (int){ 10 }
  xb1: (_|_){
    // [cycle] xb1: 4 errors in empty disjunction:
    // xb2: unresolved disjunction: xb3:
    //     ./in.cue:9:6
    // xb3: 3 errors in empty disjunction::
    //     ./in.cue:9:6
    // xb3: unresolved disjunction: xb1:
    //     ./in.cue:10:13
    // xb3: cycle with field: xb2:
    //     ./in.cue:11:6
  }
  xb2: (_|_){
    // [cycle] xb2: unresolved disjunction: xb3:
    //     ./in.cue:9:6
    // xb3: cycle with field: xb2:
    //     ./in.cue:11:6
  }
  xb3: (_|_){
    // [cycle] xb2: unresolved disjunction: xb3:
    //     ./in.cue:9:6
    // xb3: 3 errors in empty disjunction::
    //     ./in.cue:9:6
    // xb3: unresolved disjunction: xb1:
    //     ./in.cue:10:13
    // xb3: cycle with field: xb2:
    //     ./in.cue:11:6
  }
  xb4: (_|_){
    // [cycle] xb2: unresolved disjunction: xb3:
    //     ./in.cue:9:6
    // xb3: cycle with field: xb2:
    //     ./in.cue:11:6
  }
  xc1: (int){ |(*(int){ 8 }, (int){ 9 }) }
  xc2: (int){ 8 }
  xc3: (int){ 6 }
  xc4: (int){ 9 }
  xc5: (int){ 10 }
  xd1: (int){ |(*(int){ 8 }, (int){ 9 }) }
  xd2: (int){ 8 }
  xd3: (int){ 6 }
  xd4: (int){ 9 }
  xd5: (int){ 10 }
  xe1: (int){ 9 }
  xe2: (int){ 8 }
  xe3: (_|_){
    // [eval] xe3: conflicting values 7 and 6:
    //     ./in.cue:35:6
    //     ./in.cue:35:10
  }
  xe4: (int){ 9 }
  xe5: (int){ 10 }
  z1: (int){ |(*(int){ 11 }, (int){ 13 }) }
  z2: (int){ 10 }
  z3: (int){ 8 }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -10,10 +10,39 @@
   xa2: (int){ 8 }
   xa3: (int){ 6 }
   xa4: (int){ 10 }
-  xb1: (int){ 8 }
-  xb2: (int){ 8 }
-  xb3: (int){ |(*(int){ 6 }, (int){ 9 }) }
-  xb4: (int){ 10 }
+  xb1: (_|_){
+    // [cycle] xb1: 4 errors in empty disjunction:
+    // xb2: unresolved disjunction: xb3:
+    //     ./in.cue:9:6
+    // xb3: 3 errors in empty disjunction::
+    //     ./in.cue:9:6
+    // xb3: unresolved disjunction: xb1:
+    //     ./in.cue:10:13
+    // xb3: cycle with field: xb2:
+    //     ./in.cue:11:6
+  }
+  xb2: (_|_){
+    // [cycle] xb2: unresolved disjunction: xb3:
+    //     ./in.cue:9:6
+    // xb3: cycle with field: xb2:
+    //     ./in.cue:11:6
+  }
+  xb3: (_|_){
+    // [cycle] xb2: unresolved disjunction: xb3:
+    //     ./in.cue:9:6
+    // xb3: 3 errors in empty disjunction::
+    //     ./in.cue:9:6
+    // xb3: unresolved disjunction: xb1:
+    //     ./in.cue:10:13
+    // xb3: cycle with field: xb2:
+    //     ./in.cue:11:6
+  }
+  xb4: (_|_){
+    // [cycle] xb2: unresolved disjunction: xb3:
+    //     ./in.cue:9:6
+    // xb3: cycle with field: xb2:
+    //     ./in.cue:11:6
+  }
   xc1: (int){ |(*(int){ 8 }, (int){ 9 }) }
   xc2: (int){ 8 }
   xc3: (int){ 6 }
-- diff/todo/p2 --
xb*: cycles are not broken if between disjuncts if they are within expressions.
-- out/eval --
Errors:
xe3: conflicting values 7 and 6:
    ./in.cue:35:6
    ./in.cue:35:10

Result:
(_|_){
  // [eval]
  xa1: (int){ 8 }
  xa2: (int){ 8 }
  xa3: (int){ 6 }
  xa4: (int){ 10 }
  xb1: (int){ 8 }
  xb2: (int){ 8 }
  xb3: (int){ |(*(int){ 6 }, (int){ 9 }) }
  xb4: (int){ 10 }
  xc1: (int){ |(*(int){ 8 }, (int){ 9 }) }
  xc2: (int){ 8 }
  xc3: (int){ 6 }
  xc4: (int){ 9 }
  xc5: (int){ 10 }
  xd1: (int){ |(*(int){ 8 }, (int){ 9 }) }
  xd2: (int){ 8 }
  xd3: (int){ 6 }
  xd4: (int){ 9 }
  xd5: (int){ 10 }
  xe1: (int){ 9 }
  xe2: (int){ 8 }
  xe3: (_|_){
    // [eval] xe3: conflicting values 7 and 6:
    //     ./in.cue:35:6
    //     ./in.cue:35:10
  }
  xe4: (int){ 9 }
  xe5: (int){ 10 }
  z1: (int){ |(*(int){ 11 }, (int){ 13 }) }
  z2: (int){ 10 }
  z3: (int){ 8 }
}