cuelang.org/go@v0.13.0/cue/testdata/cycle/052_resolved_self-reference_cycles_with_disjunction_with_defaults.txtar (about) 1 #name: resolved self-reference cycles with disjunction with defaults 2 #evalPartial 3 -- in.cue -- 4 // The disjunction in xa could be resolved, but as disjunctions 5 // are not resolved for expression, it remains unresolved. 6 xa1: (xa2 & 8) | *(xa4 & 9) 7 xa2: xa3 + 2 8 xa3: 6 & xa1-2 9 xa4: xa2 + 2 10 11 xb1: *(xb2 & 8) | (xb4 & 9) 12 xb2: xb3 + 2 13 xb3: *(6 & (xb1 - 2)) | (xb4 & 9) 14 xb4: xb2 + 2 15 16 // Another variant with more disjunctions. xc1 remains with two 17 // possibilities. Technically, only the first value is valid. 18 // However, to fully determine that, all options of the remaining 19 // disjunction will have to be evaluated algebraically, which is 20 // not done. 21 xc1: *(xc2 & 8) | (xc4 & 9) | (xc5 & 9) 22 xc2: xc3 + 2 23 xc3: 6 & xc1-2 24 xc4: xc2 + 1 25 xc5: xc2 + 2 26 27 // The above is resolved by setting xd1 explicitly. 28 xd1: *(xd2 & 8) | xd4 & 9 | xd5 & 9 29 xd2: xd3 + 2 30 xd3: 6 & xd1-2 31 xd4: xd2 + 1 32 xd5: xd2 + 2 33 34 // The above is resolved by setting xd1 explicitly to the wrong 35 // value, resulting in an error. 36 xe1: *(xe2 & 8) | xe4 & 9 | xe5 & 9 37 xe2: xe3 + 2 38 xe3: 6 & xe1-2 39 xe4: xe2 + 1 40 xe5: xe2 + 2 41 xe1: 9 42 43 z1: *(z2 + 1) | z3+5 44 z2: z3 + 2 45 z3: z1 - 3 46 z3: 8 47 -- out/def -- 48 // The disjunction in xa could be resolved, but as disjunctions 49 // are not resolved for expression, it remains unresolved. 50 xa1: 8 51 xa2: 8 52 xa4: 10 53 xa3: 6 54 55 // As xb3 is a disjunction, xb2 cannot be resolved and evaluating 56 // the cycle completely is broken. However, it is not an error 57 // as the user might still resolve the disjunction. 58 xb1: 8 59 xb2: 8 60 xb4: 10 61 xb3: 6 62 63 // Another variant with more disjunctions. xc1 remains with two 64 // possibilities. Technically, only the first value is valid. 65 // However, to fully determine that, all options of the remaining 66 // disjunction will have to be evaluated algebraically, which is 67 // not done. 68 xc1: *8 | 9 | _|_ // conflicting values 10 and 9 69 xc2: 8 70 xc4: 9 71 xc5: 10 72 xc3: 6 73 74 // The above is resolved by setting xd1 explicitly. 75 xd1: *8 | 9 | _|_ // conflicting values 10 and 9 76 xd2: 8 77 xd4: 9 78 xd5: 10 79 xd3: 6 80 81 // The above is resolved by setting xd1 explicitly to the wrong 82 // value, resulting in an error. 83 xe1: _|_ // conflicting values 6 and 7 84 xe2: _|_ // conflicting values 6 and 7 85 xe4: _|_ // conflicting values 6 and 7 86 xe5: _|_ // conflicting values 6 and 7 87 xe3: _|_ // conflicting values 6 and 7 88 z1: *11 | 13 89 z2: 10 90 z3: 8 91 -- out/legacy-debug -- 92 <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} 93 -- out/compile -- 94 --- in.cue 95 { 96 xa1: ((〈0;xa2〉 & 8)|*(〈0;xa4〉 & 9)) 97 xa2: (〈0;xa3〉 + 2) 98 xa3: (6 & (〈0;xa1〉 - 2)) 99 xa4: (〈0;xa2〉 + 2) 100 xb1: (*(〈0;xb2〉 & 8)|(〈0;xb4〉 & 9)) 101 xb2: (〈0;xb3〉 + 2) 102 xb3: (*(6 & (〈0;xb1〉 - 2))|(〈0;xb4〉 & 9)) 103 xb4: (〈0;xb2〉 + 2) 104 xc1: (*(〈0;xc2〉 & 8)|(〈0;xc4〉 & 9)|(〈0;xc5〉 & 9)) 105 xc2: (〈0;xc3〉 + 2) 106 xc3: (6 & (〈0;xc1〉 - 2)) 107 xc4: (〈0;xc2〉 + 1) 108 xc5: (〈0;xc2〉 + 2) 109 xd1: (*(〈0;xd2〉 & 8)|(〈0;xd4〉 & 9)|(〈0;xd5〉 & 9)) 110 xd2: (〈0;xd3〉 + 2) 111 xd3: (6 & (〈0;xd1〉 - 2)) 112 xd4: (〈0;xd2〉 + 1) 113 xd5: (〈0;xd2〉 + 2) 114 xe1: (*(〈0;xe2〉 & 8)|(〈0;xe4〉 & 9)|(〈0;xe5〉 & 9)) 115 xe2: (〈0;xe3〉 + 2) 116 xe3: (6 & (〈0;xe1〉 - 2)) 117 xe4: (〈0;xe2〉 + 1) 118 xe5: (〈0;xe2〉 + 2) 119 xe1: 9 120 z1: (*(〈0;z2〉 + 1)|(〈0;z3〉 + 5)) 121 z2: (〈0;z3〉 + 2) 122 z3: (〈0;z1〉 - 3) 123 z3: 8 124 } 125 -- out/eval/stats -- 126 Leaks: 0 127 Freed: 44 128 Reused: 36 129 Allocs: 8 130 Retain: 25 131 132 Unifications: 27 133 Conjuncts: 82 134 Disjuncts: 58 135 -- out/evalalpha -- 136 Errors: 137 xe3: conflicting values 7 and 6: 138 ./in.cue:35:6 139 ./in.cue:35:10 140 141 Result: 142 (_|_){ 143 // [eval] 144 xa1: (int){ 8 } 145 xa2: (int){ 8 } 146 xa3: (int){ 6 } 147 xa4: (int){ 10 } 148 xb1: (_|_){ 149 // [cycle] xb1: 4 errors in empty disjunction: 150 // xb2: unresolved disjunction: xb3: 151 // ./in.cue:9:6 152 // xb3: 3 errors in empty disjunction:: 153 // ./in.cue:9:6 154 // xb3: unresolved disjunction: xb1: 155 // ./in.cue:10:13 156 // xb3: cycle with field: xb2: 157 // ./in.cue:11:6 158 } 159 xb2: (_|_){ 160 // [cycle] xb2: unresolved disjunction: xb3: 161 // ./in.cue:9:6 162 // xb3: cycle with field: xb2: 163 // ./in.cue:11:6 164 } 165 xb3: (_|_){ 166 // [cycle] xb2: unresolved disjunction: xb3: 167 // ./in.cue:9:6 168 // xb3: 3 errors in empty disjunction:: 169 // ./in.cue:9:6 170 // xb3: unresolved disjunction: xb1: 171 // ./in.cue:10:13 172 // xb3: cycle with field: xb2: 173 // ./in.cue:11:6 174 } 175 xb4: (_|_){ 176 // [cycle] xb2: unresolved disjunction: xb3: 177 // ./in.cue:9:6 178 // xb3: cycle with field: xb2: 179 // ./in.cue:11:6 180 } 181 xc1: (int){ |(*(int){ 8 }, (int){ 9 }) } 182 xc2: (int){ 8 } 183 xc3: (int){ 6 } 184 xc4: (int){ 9 } 185 xc5: (int){ 10 } 186 xd1: (int){ |(*(int){ 8 }, (int){ 9 }) } 187 xd2: (int){ 8 } 188 xd3: (int){ 6 } 189 xd4: (int){ 9 } 190 xd5: (int){ 10 } 191 xe1: (int){ 9 } 192 xe2: (int){ 8 } 193 xe3: (_|_){ 194 // [eval] xe3: conflicting values 7 and 6: 195 // ./in.cue:35:6 196 // ./in.cue:35:10 197 } 198 xe4: (int){ 9 } 199 xe5: (int){ 10 } 200 z1: (int){ |(*(int){ 11 }, (int){ 13 }) } 201 z2: (int){ 10 } 202 z3: (int){ 8 } 203 } 204 -- diff/-out/evalalpha<==>+out/eval -- 205 diff old new 206 --- old 207 +++ new 208 @@ -10,10 +10,39 @@ 209 xa2: (int){ 8 } 210 xa3: (int){ 6 } 211 xa4: (int){ 10 } 212 - xb1: (int){ 8 } 213 - xb2: (int){ 8 } 214 - xb3: (int){ |(*(int){ 6 }, (int){ 9 }) } 215 - xb4: (int){ 10 } 216 + xb1: (_|_){ 217 + // [cycle] xb1: 4 errors in empty disjunction: 218 + // xb2: unresolved disjunction: xb3: 219 + // ./in.cue:9:6 220 + // xb3: 3 errors in empty disjunction:: 221 + // ./in.cue:9:6 222 + // xb3: unresolved disjunction: xb1: 223 + // ./in.cue:10:13 224 + // xb3: cycle with field: xb2: 225 + // ./in.cue:11:6 226 + } 227 + xb2: (_|_){ 228 + // [cycle] xb2: unresolved disjunction: xb3: 229 + // ./in.cue:9:6 230 + // xb3: cycle with field: xb2: 231 + // ./in.cue:11:6 232 + } 233 + xb3: (_|_){ 234 + // [cycle] xb2: unresolved disjunction: xb3: 235 + // ./in.cue:9:6 236 + // xb3: 3 errors in empty disjunction:: 237 + // ./in.cue:9:6 238 + // xb3: unresolved disjunction: xb1: 239 + // ./in.cue:10:13 240 + // xb3: cycle with field: xb2: 241 + // ./in.cue:11:6 242 + } 243 + xb4: (_|_){ 244 + // [cycle] xb2: unresolved disjunction: xb3: 245 + // ./in.cue:9:6 246 + // xb3: cycle with field: xb2: 247 + // ./in.cue:11:6 248 + } 249 xc1: (int){ |(*(int){ 8 }, (int){ 9 }) } 250 xc2: (int){ 8 } 251 xc3: (int){ 6 } 252 -- diff/todo/p2 -- 253 xb*: cycles are not broken if between disjuncts if they are within expressions. 254 -- out/eval -- 255 Errors: 256 xe3: conflicting values 7 and 6: 257 ./in.cue:35:6 258 ./in.cue:35:10 259 260 Result: 261 (_|_){ 262 // [eval] 263 xa1: (int){ 8 } 264 xa2: (int){ 8 } 265 xa3: (int){ 6 } 266 xa4: (int){ 10 } 267 xb1: (int){ 8 } 268 xb2: (int){ 8 } 269 xb3: (int){ |(*(int){ 6 }, (int){ 9 }) } 270 xb4: (int){ 10 } 271 xc1: (int){ |(*(int){ 8 }, (int){ 9 }) } 272 xc2: (int){ 8 } 273 xc3: (int){ 6 } 274 xc4: (int){ 9 } 275 xc5: (int){ 10 } 276 xd1: (int){ |(*(int){ 8 }, (int){ 9 }) } 277 xd2: (int){ 8 } 278 xd3: (int){ 6 } 279 xd4: (int){ 9 } 280 xd5: (int){ 10 } 281 xe1: (int){ 9 } 282 xe2: (int){ 8 } 283 xe3: (_|_){ 284 // [eval] xe3: conflicting values 7 and 6: 285 // ./in.cue:35:6 286 // ./in.cue:35:10 287 } 288 xe4: (int){ 9 } 289 xe5: (int){ 10 } 290 z1: (int){ |(*(int){ 11 }, (int){ 13 }) } 291 z2: (int){ 10 } 292 z3: (int){ 8 } 293 }