github.com/solo-io/cue@v0.4.7/cue/testdata/cycle/051_resolved_self-reference_cycles_with_disjunction.txtar (about) 1 #name: resolved self-reference cycles with disjunction 2 #evalPartial 3 4 // TODO(cycle) 5 // 6 // Some of these examples used to work, but the changes corresponding to this 7 // addition, it ceased to do so. Fixing these cycle issues seemed more 8 // important than keeping this esoteric case working, which was already broken 9 // in the last release anyway. 10 // 11 // Reproducer of underlying problem. Still works, but triggers unexpected 12 // condition. 13 // 14 // xb1: xb2 15 // xb2: xb3 16 // xb3: xb2 + 0 17 18 -- in.cue -- 19 // The second disjunct in xa1 is not resolvable and can be 20 // eliminated: 21 // xa4 & 9 22 // (xa2 + 2) & 9 23 // ((xa3 + 2) + 2) & 9 24 // (((6 & xa1-2) + 2) + 2) & 9 25 // ((6 + 2) + 2) & 9 // 6 == xa1-2 26 // 10 & 9 => _|_ 27 // The remaining values resolve. 28 xa1: (xa2 & 8) | (xa4 & 9) 29 xa2: xa3 + 2 30 xa3: 6 & xa1-2 31 xa4: xa2 + 2 32 33 // The second disjunct of xb1 can be eliminated as both disjuncts 34 // of xb3 result in an incompatible sum when substituted. 35 xb1: (xb2 & 8) | (xb4 & 9) 36 xb2: xb3 + 2 37 xb3: (6 & (xb1 - 2)) | (xb4 & 9) 38 xb4: xb2 + 2 39 40 // Another variant with more disjunctions. xc1 remains with two 41 // possibilities. Technically, only the first value is valid. 42 // However, to fully determine that, all options of the remaining 43 // disjunction will have to be evaluated algebraically, which is 44 // not done. 45 xc1: xc2 & 8 | xc4 & 9 | xc5 & 9 46 xc2: xc3 + 2 47 xc3: 6 & xc1-2 48 xc4: xc2 + 1 49 xc5: xc2 + 2 50 51 // The below is resolved by setting xd1 explicitly. 52 xd1: xd2 & 8 | xd4 & 9 | xd5 & 9 53 xd2: xd3 + 2 54 xd3: 6 & xd1-2 55 xd4: xd2 + 1 56 xd5: xd2 + 2 57 xd1: 8 58 59 // The below is resolved by setting xd1 explicitly to the wrong 60 // value, resulting in an error. 61 xe1: xe2 & 8 | xe4 & 9 | xe5 & 9 62 xe2: xe3 + 2 63 xe3: 6 & xe1-2 64 xe4: xe2 + 1 65 xe5: xe2 + 2 66 xe1: 9 67 68 // Only one solution. 69 xf1: xf2 & 8 | xf4 & 9 70 xf2: xf3 + 2 71 xf3: 6 & xf1-2 | xf4 & 9 72 xf4: xf2 + 2 73 74 z1: z2+1 | z3+5 // +3 for fun 75 z2: z3 + 2 76 z3: z1 - 3 77 z3: 8 78 -- out/def -- 79 // The second disjunct in xa1 is not resolvable and can be 80 // eliminated: 81 // xa4 & 9 82 // (xa2 + 2) & 9 83 // ((xa3 + 2) + 2) & 9 84 // (((6 & xa1-2) + 2) + 2) & 9 85 // ((6 + 2) + 2) & 9 // 6 == xa1-2 86 // 10 & 9 => _|_ 87 // The remaining values resolve. 88 xa1: 8 89 xa2: 8 90 xa4: 10 91 xa3: 6 92 93 // The second disjunct in xb4 can be eliminated as both disjuncts 94 // of xb3 result in an incompatible sum when substituted. 95 xb1: 8 96 xb2: 8 97 xb4: 10 98 xb3: 6 99 100 // Another variant with more disjunctions. xc1 remains with two 101 // possibilities. Technically, only the first value is valid. 102 // However, to fully determine that, all options of the remaining 103 // disjunction will have to be evaluated algebraically, which is 104 // not done. 105 xc1: xc2 & 8 | xc4 & 9 | xc5 & 9 106 xc2: xc3 + 2 107 xc4: xc2 + 1 108 xc5: xc2 + 2 109 xc3: 6 & xc1-2 110 111 // The above is resolved by setting xd1 explicitly. 112 xd1: 8 113 xd2: 8 114 xd4: 9 115 xd5: 10 116 xd3: 6 117 118 // The above is resolved by setting xd1 explicitly to the wrong 119 // value, resulting in an error. 120 xe1: _|_ // conflicting values 6 and 7 121 xe2: _|_ // conflicting values 6 and 7 122 xe4: _|_ // conflicting values 6 and 7 123 xe5: _|_ // conflicting values 6 and 7 124 xe3: _|_ // conflicting values 6 and 7 125 126 // Only one solution. 127 xf1: 8 128 xf2: 8 129 xf4: 10 130 xf3: 6 131 z1: z2+1 | z3+5 132 z2: z3 + 2 133 z3: z1-3 & 8 134 -- out/legacy-debug -- 135 <0>{xa1: 8, xa2: 8, xa4: 10, xa3: 6, xb1: 8, xb2: 8, xb4: 10, xb3: 6, xc1: ((<1>.xc2 & 8) | (<1>.xc4 & 9) | (<1>.xc5 & 9)), xc2: (<1>.xc3 + 2), xc4: (<1>.xc2 + 1), xc5: (<1>.xc2 + 2), xc3: (6 & (<1>.xc1 - 2)), xd1: 8, 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), xf1: 8, xf2: 8, xf4: 10, xf3: 6, z1: ((<1>.z2 + 1) | (<1>.z3 + 5)), z2: (<1>.z3 + 2), z3: ((<1>.z1 - 3) & 8)} 136 -- out/compile -- 137 --- in.cue 138 { 139 xa1: ((〈0;xa2〉 & 8)|(〈0;xa4〉 & 9)) 140 xa2: (〈0;xa3〉 + 2) 141 xa3: (6 & (〈0;xa1〉 - 2)) 142 xa4: (〈0;xa2〉 + 2) 143 xb1: ((〈0;xb2〉 & 8)|(〈0;xb4〉 & 9)) 144 xb2: (〈0;xb3〉 + 2) 145 xb3: ((6 & (〈0;xb1〉 - 2))|(〈0;xb4〉 & 9)) 146 xb4: (〈0;xb2〉 + 2) 147 xc1: ((〈0;xc2〉 & 8)|(〈0;xc4〉 & 9)|(〈0;xc5〉 & 9)) 148 xc2: (〈0;xc3〉 + 2) 149 xc3: (6 & (〈0;xc1〉 - 2)) 150 xc4: (〈0;xc2〉 + 1) 151 xc5: (〈0;xc2〉 + 2) 152 xd1: ((〈0;xd2〉 & 8)|(〈0;xd4〉 & 9)|(〈0;xd5〉 & 9)) 153 xd2: (〈0;xd3〉 + 2) 154 xd3: (6 & (〈0;xd1〉 - 2)) 155 xd4: (〈0;xd2〉 + 1) 156 xd5: (〈0;xd2〉 + 2) 157 xd1: 8 158 xe1: ((〈0;xe2〉 & 8)|(〈0;xe4〉 & 9)|(〈0;xe5〉 & 9)) 159 xe2: (〈0;xe3〉 + 2) 160 xe3: (6 & (〈0;xe1〉 - 2)) 161 xe4: (〈0;xe2〉 + 1) 162 xe5: (〈0;xe2〉 + 2) 163 xe1: 9 164 xf1: ((〈0;xf2〉 & 8)|(〈0;xf4〉 & 9)) 165 xf2: (〈0;xf3〉 + 2) 166 xf3: ((6 & (〈0;xf1〉 - 2))|(〈0;xf4〉 & 9)) 167 xf4: (〈0;xf2〉 + 2) 168 z1: ((〈0;z2〉 + 1)|(〈0;z3〉 + 5)) 169 z2: (〈0;z3〉 + 2) 170 z3: (〈0;z1〉 - 3) 171 z3: 8 172 } 173 -- out/eval -- 174 Errors: 175 xe1: 2 errors in empty disjunction: 176 xe1: conflicting values 8 and 9: 177 ./in.cue:43:12 178 ./in.cue:48:6 179 xe3: conflicting values 7 and 6: 180 ./in.cue:45:6 181 ./in.cue:45:10 182 183 Result: 184 (_|_){ 185 // [eval] 186 xa1: (int){ 8 } 187 xa2: (int){ 8 } 188 xa3: (int){ 6 } 189 xa4: (int){ 10 } 190 xb1: (int){ 9 } 191 xb2: (_|_){ 192 // [incomplete] xb2: unresolved disjunction 6 | 9 (type int): 193 // ./in.cue:18:6 194 } 195 xb3: (int){ |((int){ 6 }, (int){ 9 }) } 196 xb4: (_|_){ 197 // [incomplete] xb2: unresolved disjunction 6 | 9 (type int): 198 // ./in.cue:18:6 199 } 200 xc1: (int){ |((int){ 8 }, (int){ 9 }) } 201 xc2: (int){ 8 } 202 xc3: (_|_){ 203 // [incomplete] xc3: unresolved disjunction 8 | 9 (type int): 204 // ./in.cue:29:10 205 } 206 xc4: (int){ 9 } 207 xc5: (int){ 10 } 208 xd1: (int){ 8 } 209 xd2: (int){ 8 } 210 xd3: (int){ 6 } 211 xd4: (int){ 9 } 212 xd5: (int){ 10 } 213 xe1: (_|_){ 214 // [eval] xe1: 2 errors in empty disjunction: 215 // xe1: conflicting values 8 and 9: 216 // ./in.cue:43:12 217 // ./in.cue:48:6 218 // xe3: conflicting values 7 and 6: 219 // ./in.cue:45:6 220 // ./in.cue:45:10 221 } 222 xe2: (_|_){ 223 // [eval] xe3: conflicting values 7 and 6: 224 // ./in.cue:45:6 225 // ./in.cue:45:10 226 } 227 xe3: (_|_){ 228 // [eval] xe3: conflicting values 7 and 6: 229 // ./in.cue:45:6 230 // ./in.cue:45:10 231 } 232 xe4: (_|_){ 233 // [eval] xe3: conflicting values 7 and 6: 234 // ./in.cue:45:6 235 // ./in.cue:45:10 236 } 237 xe5: (_|_){ 238 // [eval] xe3: conflicting values 7 and 6: 239 // ./in.cue:45:6 240 // ./in.cue:45:10 241 } 242 xf1: (int){ 9 } 243 xf2: (_|_){ 244 // [incomplete] xf2: unresolved disjunction 6 | 9 (type int): 245 // ./in.cue:52:6 246 } 247 xf3: (int){ |((int){ 6 }, (int){ 9 }) } 248 xf4: (_|_){ 249 // [incomplete] xf2: unresolved disjunction 6 | 9 (type int): 250 // ./in.cue:52:6 251 } 252 z1: (int){ |((int){ 11 }, (int){ 13 }) } 253 z2: (int){ 10 } 254 z3: (_|_){ 255 // [incomplete] z3: unresolved disjunction 11 | 13 (type int): 256 // ./in.cue:58:5 257 } 258 }