github.com/solo-io/cue@v0.4.7/internal/core/export/testdata/alias.txtar (about) 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 -- 7 fieldAlias: simple: { 8 X="a-b": 4 9 foo: X 10 11 bar?: Y 12 13 Y="a-c": 5 14 } 15 16 valueAlias: 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 23 valueAlias: selfRef: struct: { 24 a: b: X={ #foo: X.b, b: 2 } 25 } 26 27 valueAlias: 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 37 valueAlias: 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 44 -- y.cue -- 45 fieldAlias: cross: { 46 baz: 3 47 X="d-2": E=[D="cue"]: C="foo\(baz)": { 48 name: "xx" 49 foo: C.name 50 bar: X 51 baz: D 52 qux: E 53 } 54 } 55 -- out/definition -- 56 fieldAlias: { 57 simple: { 58 X_1="a-b": 4 59 foo: X_1 60 bar?: Y_1 61 Y_1="a-c": 5 62 } 63 cross: { 64 baz: 3 65 X_85="d-2": { 66 E=[D="cue"]: { 67 C="foo\(baz)": { 68 name: "xx" 69 foo: C.name 70 bar: X_85 71 baz: D 72 qux: E 73 } 74 } 75 } 76 } 77 } 78 valueAlias: { 79 merge: { 80 // Merge fields, rename alias to avoid conflict. 81 // TODO: merged values can still be simplified. 82 value: X_BA={ 83 #value: X_BA.b & X_BA.b 84 b: 2 85 v: { 86 X: 3 87 } 88 } 89 } 90 selfRef: { 91 struct: { 92 a: { 93 b: X_57C8={ 94 #foo: X_57C8.b 95 b: 2 96 } 97 } 98 } 99 } 100 selfRefValue: { 101 struct: { 102 // Note: this resolves to a cycle error, which is considered 103 // to be equal to "incomplete". As a result, in case of 104 // non-final evaluation, reference will remain. This is not 105 // an issue exclusive to value aliases, and falls within the 106 // range of what is acceptable for now. 107 // TODO: solve this issue. 108 a: X_35B7E=or(X_35B7E) 109 } 110 pattern: { 111 // this triggers the verbatim "adt" path. Note that there 112 // is no need to rename the variable here as the expression 113 // was known to compile and is known to be correct. 114 a: { 115 [string]: X=or(X) 116 } 117 } 118 } 119 } 120 -- out/doc -- 121 [] 122 [fieldAlias] 123 [fieldAlias simple] 124 [fieldAlias simple "a-b"] 125 [fieldAlias simple foo] 126 [fieldAlias simple "a-c"] 127 [fieldAlias cross] 128 [fieldAlias cross baz] 129 [fieldAlias cross "d-2"] 130 [valueAlias] 131 [valueAlias merge] 132 [valueAlias merge value] 133 - Merge fields, rename alias to avoid conflict. 134 TODO: merged values can still be simplified. 135 136 [valueAlias merge value #value] 137 [valueAlias merge value b] 138 [valueAlias merge value v] 139 [valueAlias merge value v X] 140 [valueAlias selfRef] 141 [valueAlias selfRef struct] 142 [valueAlias selfRef struct a] 143 [valueAlias selfRef struct a b] 144 [valueAlias selfRef struct a b #foo] 145 [valueAlias selfRef struct a b b] 146 [valueAlias selfRefValue] 147 [valueAlias selfRefValue struct] 148 [valueAlias selfRefValue struct a] 149 - Note: this resolves to a cycle error, which is considered 150 to be equal to "incomplete". As a result, in case of 151 non-final evaluation, reference will remain. This is not 152 an issue exclusive to value aliases, and falls within the 153 range of what is acceptable for now. 154 TODO: solve this issue. 155 156 [valueAlias selfRefValue pattern] 157 [valueAlias selfRefValue pattern a] 158 - this triggers the verbatim "adt" path. Note that there 159 is no need to rename the variable here as the expression 160 was known to compile and is known to be correct. 161 162 -- out/value -- 163 == Simplified 164 { 165 fieldAlias: { 166 simple: { 167 "a-b": 4 168 foo: 4 169 "a-c": 5 170 } 171 cross: { 172 baz: 3 173 "d-2": {} 174 } 175 } 176 valueAlias: { 177 merge: { 178 // Merge fields, rename alias to avoid conflict. 179 // TODO: merged values can still be simplified. 180 value: { 181 b: 2 182 v: { 183 X: 3 184 } 185 } 186 } 187 selfRef: { 188 struct: { 189 a: { 190 b: { 191 b: 2 192 } 193 } 194 } 195 } 196 selfRefValue: { 197 struct: { 198 // Note: this resolves to a cycle error, which is considered 199 // to be equal to "incomplete". As a result, in case of 200 // non-final evaluation, reference will remain. This is not 201 // an issue exclusive to value aliases, and falls within the 202 // range of what is acceptable for now. 203 // TODO: solve this issue. 204 a: or(X) 205 } 206 pattern: { 207 // this triggers the verbatim "adt" path. Note that there 208 // is no need to rename the variable here as the expression 209 // was known to compile and is known to be correct. 210 a: {} 211 } 212 } 213 } 214 } 215 == Raw 216 { 217 fieldAlias: { 218 simple: { 219 "a-b": 4 220 foo: 4 221 bar?: Y_1 222 Y_1="a-c": 5 223 } 224 cross: { 225 baz: 3 226 "d-2": {} 227 } 228 } 229 valueAlias: { 230 merge: { 231 // Merge fields, rename alias to avoid conflict. 232 // TODO: merged values can still be simplified. 233 value: { 234 #value: 2 235 b: 2 236 v: { 237 X: 3 238 } 239 } 240 } 241 selfRef: { 242 struct: { 243 a: { 244 b: { 245 #foo: 2 246 b: 2 247 } 248 } 249 } 250 } 251 selfRefValue: { 252 struct: { 253 // Note: this resolves to a cycle error, which is considered 254 // to be equal to "incomplete". As a result, in case of 255 // non-final evaluation, reference will remain. This is not 256 // an issue exclusive to value aliases, and falls within the 257 // range of what is acceptable for now. 258 // TODO: solve this issue. 259 a: or(X) 260 } 261 pattern: { 262 // this triggers the verbatim "adt" path. Note that there 263 // is no need to rename the variable here as the expression 264 // was known to compile and is known to be correct. 265 a: {} 266 } 267 } 268 } 269 } 270 == Final 271 { 272 fieldAlias: { 273 simple: { 274 "a-b": 4 275 foo: 4 276 "a-c": 5 277 } 278 cross: { 279 baz: 3 280 "d-2": {} 281 } 282 } 283 valueAlias: { 284 merge: { 285 value: { 286 b: 2 287 v: { 288 X: 3 289 } 290 } 291 } 292 selfRef: { 293 struct: { 294 a: { 295 b: { 296 b: 2 297 } 298 } 299 } 300 } 301 selfRefValue: { 302 struct: { 303 a: _|_ // cycle error 304 } 305 pattern: { 306 a: {} 307 } 308 } 309 } 310 } 311 == All 312 { 313 fieldAlias: { 314 simple: { 315 "a-b": 4 316 foo: 4 317 bar?: Y_1 318 Y_1="a-c": 5 319 } 320 cross: { 321 baz: 3 322 "d-2": {} 323 } 324 } 325 valueAlias: { 326 merge: { 327 // Merge fields, rename alias to avoid conflict. 328 // TODO: merged values can still be simplified. 329 value: { 330 #value: 2 331 b: 2 332 v: { 333 X: 3 334 } 335 } 336 } 337 selfRef: { 338 struct: { 339 a: { 340 b: { 341 #foo: 2 342 b: 2 343 } 344 } 345 } 346 } 347 selfRefValue: { 348 struct: { 349 // Note: this resolves to a cycle error, which is considered 350 // to be equal to "incomplete". As a result, in case of 351 // non-final evaluation, reference will remain. This is not 352 // an issue exclusive to value aliases, and falls within the 353 // range of what is acceptable for now. 354 // TODO: solve this issue. 355 a: or(X) 356 } 357 pattern: { 358 // this triggers the verbatim "adt" path. Note that there 359 // is no need to rename the variable here as the expression 360 // was known to compile and is known to be correct. 361 a: {} 362 } 363 } 364 } 365 } 366 == Eval 367 { 368 fieldAlias: { 369 simple: { 370 "a-b": 4 371 foo: 4 372 bar?: Y_1 373 Y_1="a-c": 5 374 } 375 cross: { 376 baz: 3 377 "d-2": {} 378 } 379 } 380 valueAlias: { 381 merge: { 382 value: { 383 #value: 2 384 b: 2 385 v: { 386 X: 3 387 } 388 } 389 } 390 selfRef: { 391 struct: { 392 a: { 393 b: { 394 #foo: 2 395 b: 2 396 } 397 } 398 } 399 } 400 selfRefValue: { 401 struct: { 402 a: or(X) 403 } 404 pattern: { 405 a: {} 406 } 407 } 408 } 409 }