cuelang.org/go@v0.10.1/cue/testdata/comprehensions/checkdefined.txtar (about) 1 2 Issue #1969 3 4 -- in.cue -- 5 import "list" 6 7 // All tests here should pass and the result of the okcN tests should be 8 // identical to those of the okoN tests. 9 10 xc: close({field: {}}) 11 xo: field: {} 12 13 okc0: { if xc.undefined == _|_ {a: 1} } 14 oko0: { if xo.undefined == _|_ {a: 1} } 15 16 okc1: { if xc.undefined != _|_ {a: 1} } 17 oko1: { if xo.undefined != _|_ {a: 1} } 18 19 okc2: { 20 if ({} & {s: [for y in xc.undefined {}]}) != _|_ {a: 1} 21 } 22 23 oko2: { 24 if ({} & {s: [for y in xo.undefined {}]}) != _|_ {a: 1} 25 } 26 27 okc3: { 28 if ({s: [for y in xc.undefined {}]}) != _|_ {a: 1} 29 } 30 31 oko3: { 32 if ({s: [for y in xo.undefined {}]}) != _|_ {a: 1} 33 } 34 35 // Should Field s exist in okc or not? Depends on whether comparison to bottom 36 // is recursive or not. It probably should not. 37 // TODO: fix for new evaluator. But possibly address this with new builtins. 38 issue1969: okc: { 39 let X = xc.undefined 40 let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} 41 42 if Y != _|_ {Y} 43 } 44 45 issue1969: oko: { 46 let X = xo.undefined 47 let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} 48 49 if Y != _|_ {Y} 50 } 51 -- issue2245.cue -- 52 yo: { f: int, g: f < 10 } 53 okyo: { if yo != _|_ {a: 1} } 54 okyog: { if yo.g != _|_ {a: 1} } 55 56 -- incomplete.cue -- 57 // Comparing to string is not an error. But for legacy reasons we want to still 58 // support this. We intend to have more clean and precise behavior with the 59 // builtins isdefined, isvalid, and isconcrete. 60 checkIncomplete: t1: { 61 f: [string]: { 62 if a != _|_ { 63 b: "d\(a)" 64 } 65 a: string 66 } 67 f: blah: {} 68 } 69 70 -- structs.cue -- 71 structs: { 72 bare: t1: ({y: 2} & {x: 3}) != _|_ 73 bare: f2: ({y: 2} & {x: 3}) == _|_ 74 bare: f3: ({x: 1, y: 2} & {x: 3}) != _|_ 75 bare: t4: ({x: 1, y: 2} & {x: 3}) == _|_ 76 77 select: t1: ({y: 2} & {x: 3}).y != _|_ 78 select: f2: ({y: 2} & {x: 3}).y == _|_ 79 select: f3: ({x: 1, y: 2} & {x: 3}).y != _|_ 80 select: t4: ({x: 1, y: 2} & {x: 3}).y == _|_ 81 } 82 83 -- out/eval/stats -- 84 Leaks: 11 85 Freed: 89 86 Reused: 85 87 Allocs: 15 88 Retain: 26 89 90 Unifications: 100 91 Conjuncts: 134 92 Disjuncts: 105 93 -- out/eval -- 94 (struct){ 95 xc: (#struct){ 96 field: (struct){ 97 } 98 } 99 xo: (struct){ 100 field: (struct){ 101 } 102 } 103 okc0: (struct){ 104 a: (int){ 1 } 105 } 106 oko0: (struct){ 107 a: (int){ 1 } 108 } 109 okc1: (struct){ 110 } 111 oko1: (struct){ 112 } 113 okc2: (struct){ 114 } 115 oko2: (struct){ 116 a: (int){ 1 } 117 } 118 okc3: (struct){ 119 } 120 oko3: (struct){ 121 a: (int){ 1 } 122 } 123 issue1969: (struct){ 124 okc: (struct){ 125 let X#1 = (_|_){ 126 // [eval] issue1969.okc.X: undefined field: undefined: 127 // ./in.cue:35:13 128 } 129 let Y#2 = (_|_){ 130 // [eval] 131 s: (_|_){ 132 // [eval] issue1969.okc.X: undefined field: undefined: 133 // ./in.cue:35:13 134 } 135 } 136 } 137 oko: (struct){ 138 let X#3 = (_|_){ 139 // [incomplete] issue1969.oko.X: undefined field: undefined: 140 // ./in.cue:42:13 141 } 142 let Y#4 = (struct){ 143 s: (_|_){ 144 // [incomplete] issue1969.oko.X: undefined field: undefined: 145 // ./in.cue:42:13 146 } 147 } 148 s: (_|_){ 149 // [incomplete] issue1969.oko.X: undefined field: undefined: 150 // ./in.cue:42:13 151 } 152 } 153 } 154 checkIncomplete: (struct){ 155 t1: (struct){ 156 f: (struct){ 157 blah: (struct){ 158 a: (string){ string } 159 } 160 } 161 } 162 } 163 yo: (struct){ 164 f: (int){ int } 165 g: (_|_){ 166 // [incomplete] yo.g: non-concrete value int in operand to <: 167 // ./issue2245.cue:1:18 168 // ./issue2245.cue:1:10 169 } 170 } 171 okyo: (struct){ 172 a: (int){ 1 } 173 } 174 okyog: (struct){ 175 } 176 structs: (struct){ 177 bare: (struct){ 178 t1: (bool){ true } 179 f2: (bool){ false } 180 f3: (bool){ false } 181 t4: (bool){ true } 182 } 183 select: (struct){ 184 t1: (bool){ true } 185 f2: (bool){ false } 186 f3: (bool){ false } 187 t4: (bool){ true } 188 } 189 } 190 } 191 -- out/compile -- 192 --- in.cue 193 { 194 xc: close({ 195 field: {} 196 }) 197 xo: { 198 field: {} 199 } 200 okc0: { 201 if (〈1;xc〉.undefined == _|_(explicit error (_|_ literal) in source)) { 202 a: 1 203 } 204 } 205 oko0: { 206 if (〈1;xo〉.undefined == _|_(explicit error (_|_ literal) in source)) { 207 a: 1 208 } 209 } 210 okc1: { 211 if (〈1;xc〉.undefined != _|_(explicit error (_|_ literal) in source)) { 212 a: 1 213 } 214 } 215 oko1: { 216 if (〈1;xo〉.undefined != _|_(explicit error (_|_ literal) in source)) { 217 a: 1 218 } 219 } 220 okc2: { 221 if (({} & { 222 s: [ 223 for _, y in 〈3;xc〉.undefined {}, 224 ] 225 }) != _|_(explicit error (_|_ literal) in source)) { 226 a: 1 227 } 228 } 229 oko2: { 230 if (({} & { 231 s: [ 232 for _, y in 〈3;xo〉.undefined {}, 233 ] 234 }) != _|_(explicit error (_|_ literal) in source)) { 235 a: 1 236 } 237 } 238 okc3: { 239 if ({ 240 s: [ 241 for _, y in 〈3;xc〉.undefined {}, 242 ] 243 } != _|_(explicit error (_|_ literal) in source)) { 244 a: 1 245 } 246 } 247 oko3: { 248 if ({ 249 s: [ 250 for _, y in 〈3;xo〉.undefined {}, 251 ] 252 } != _|_(explicit error (_|_ literal) in source)) { 253 a: 1 254 } 255 } 256 issue1969: { 257 okc: { 258 let X#1 = 〈2;xc〉.undefined 259 let Y#2 = ({} & { 260 s: [ 261 for _, y in 〈import;list〉.Range(0, 〈2;let X#1〉, 1) {}, 262 ] 263 }) 264 if (〈0;let Y#2〉 != _|_(explicit error (_|_ literal) in source)) { 265 〈1;let Y#2〉 266 } 267 } 268 } 269 issue1969: { 270 oko: { 271 let X#3 = 〈2;xo〉.undefined 272 let Y#4 = ({} & { 273 s: [ 274 for _, y in 〈import;list〉.Range(0, 〈2;let X#3〉, 1) {}, 275 ] 276 }) 277 if (〈0;let Y#4〉 != _|_(explicit error (_|_ literal) in source)) { 278 〈1;let Y#4〉 279 } 280 } 281 } 282 } 283 --- incomplete.cue 284 { 285 checkIncomplete: { 286 t1: { 287 f: { 288 [string]: { 289 if (〈0;a〉 != _|_(explicit error (_|_ literal) in source)) { 290 b: "d\(〈1;a〉)" 291 } 292 a: string 293 } 294 } 295 f: { 296 blah: {} 297 } 298 } 299 } 300 } 301 --- issue2245.cue 302 { 303 yo: { 304 f: int 305 g: (〈0;f〉 < 10) 306 } 307 okyo: { 308 if (〈1;yo〉 != _|_(explicit error (_|_ literal) in source)) { 309 a: 1 310 } 311 } 312 okyog: { 313 if (〈1;yo〉.g != _|_(explicit error (_|_ literal) in source)) { 314 a: 1 315 } 316 } 317 } 318 --- structs.cue 319 { 320 structs: { 321 bare: { 322 t1: (({ 323 y: 2 324 } & { 325 x: 3 326 }) != _|_(explicit error (_|_ literal) in source)) 327 } 328 bare: { 329 f2: (({ 330 y: 2 331 } & { 332 x: 3 333 }) == _|_(explicit error (_|_ literal) in source)) 334 } 335 bare: { 336 f3: (({ 337 x: 1 338 y: 2 339 } & { 340 x: 3 341 }) != _|_(explicit error (_|_ literal) in source)) 342 } 343 bare: { 344 t4: (({ 345 x: 1 346 y: 2 347 } & { 348 x: 3 349 }) == _|_(explicit error (_|_ literal) in source)) 350 } 351 select: { 352 t1: (({ 353 y: 2 354 } & { 355 x: 3 356 }).y != _|_(explicit error (_|_ literal) in source)) 357 } 358 select: { 359 f2: (({ 360 y: 2 361 } & { 362 x: 3 363 }).y == _|_(explicit error (_|_ literal) in source)) 364 } 365 select: { 366 f3: (({ 367 x: 1 368 y: 2 369 } & { 370 x: 3 371 }).y != _|_(explicit error (_|_ literal) in source)) 372 } 373 select: { 374 t4: (({ 375 x: 1 376 y: 2 377 } & { 378 x: 3 379 }).y == _|_(explicit error (_|_ literal) in source)) 380 } 381 } 382 }