cuelang.org/go@v0.13.0/cue/testdata/resolve/045_range_unification.txtar (about) 1 #name: range unification 2 #evalPartial 3 -- in.cue -- 4 // with concrete values 5 a1: >=1 & <=5 & 3 6 a2: >=1 & <=5 & 1 7 a3: >=1 & <=5 & 5 8 a4: >=1 & <=5 & 6 9 a5: >=1 & <=5 & 0 10 11 a6: 3 & >=1 & <=5 12 a7: 1 & >=1 & <=5 13 a8: 5 & >=1 & <=5 14 a9: 6 & >=1 & <=5 15 a10: 0 & >=1 & <=5 16 17 // with ranges 18 b1: >=1 & <=5 & >=1 & <=5 19 b2: >=1 & <=5 & >=1 & <=1 20 b3: >=1 & <=5 & >=5 & <=5 21 b4: >=1 & <=5 & >=2 & <=3 22 b5: >=1 & <=5 & >=3 & <=9 23 b6: >=1 & <=5 & >=5 & <=9 24 b7: >=1 & <=5 & >=6 & <=9 25 26 b8: >=1 & <=5 & >=1 & <=5 27 b9: >=1 & <=1 & >=1 & <=5 28 b10: >=5 & <=5 & >=1 & <=5 29 b11: >=2 & <=3 & >=1 & <=5 30 b12: >=3 & <=9 & >=1 & <=5 31 b13: >=5 & <=9 & >=1 & <=5 32 b14: >=6 & <=9 & >=1 & <=5 33 34 // ranges with more general types 35 c1: int & >=1 & <=5 36 c2: >=1 & <=5 & int 37 c3: string & >=1 & <=5 38 c4: >=1 & <=5 & string 39 40 // other types 41 s1: >="d" & <="z" & "e" 42 s2: >="d" & <="z" & "ee" 43 44 n1: number & >=1 & <=2 45 n2: int & >=1.1 & <=1.3 46 n3: >=1.0 & <=3.0 & 2 47 n4: >=0.0 & <=0.1 & 0.09999 48 n5: >=1 & <=5 & 2.5 49 -- out/def -- 50 // with concrete values 51 a1: 3 52 a2: 1 53 a3: 5 54 a4: _|_ // invalid value 6 (out of bound <=5) 55 a5: _|_ // invalid value 0 (out of bound >=1) 56 a6: 3 57 a7: 1 58 a8: 5 59 a9: _|_ // invalid value 6 (out of bound <=5) 60 a10: _|_ // invalid value 0 (out of bound >=1) 61 62 // with ranges 63 b1: >=1 & <=5 64 b2: 1 65 b3: 5 66 b4: >=2 & <=3 67 b5: >=3 & <=5 68 b6: 5 69 b7: _|_ // conflicting bounds >=6 and <=5 70 b8: >=1 & <=5 71 b9: 1 72 b10: 5 73 b11: >=2 & <=3 74 b12: >=3 & <=5 75 b13: 5 76 b14: _|_ // conflicting bounds >=6 and <=5 77 78 // ranges with more general types 79 c1: uint & >=1 & <=5 80 c2: uint & >=1 & <=5 81 c3: _|_ // conflicting values string and >=1 (mismatched types string and number) 82 c4: _|_ // conflicting values (>=1 & <=5) and string (mismatched types number and string) 83 84 // other types 85 s1: "e" 86 s2: "ee" 87 n1: >=1 & <=2 88 n2: _|_ // conflicting bounds int & >=1.1 and <=1.3 89 n3: 2 90 n4: 0.09999 91 n5: 2.5 92 -- out/legacy-debug -- 93 <0>{a1: 3, a2: 1, a3: 5, a4: _|_((<=5 & 6):invalid value 6 (out of bound <=5)), a5: _|_((>=1 & 0):invalid value 0 (out of bound >=1)), a6: 3, a7: 1, a8: 5, a9: _|_((<=5 & 6):invalid value 6 (out of bound <=5)), a10: _|_((>=1 & 0):invalid value 0 (out of bound >=1)), b1: (>=1 & <=5), b2: 1, b3: 5, b4: (>=2 & <=3), b5: (>=3 & <=5), b6: 5, b7: _|_(conflicting bounds >=6 and <=5), b8: (>=1 & <=5), b9: 1, b10: 5, b11: (>=2 & <=3), b12: (>=3 & <=5), b13: 5, b14: _|_(conflicting bounds >=6 and <=5), c1: (int & >=1 & <=5), c2: (<=5 & int & >=1), c3: _|_((string & >=1):conflicting values string and >=1 (mismatched types string and number)), c4: _|_(((>=1 & <=5) & string):conflicting values (>=1 & <=5) and string (mismatched types number and string)), s1: "e", s2: "ee", n1: (>=1 & <=2), n2: _|_(conflicting bounds int & >=1.1 and <=1.3), n3: 2, n4: 0.09999, n5: 2.5} 94 -- out/compile -- 95 --- in.cue 96 { 97 a1: ((>=1 & <=5) & 3) 98 a2: ((>=1 & <=5) & 1) 99 a3: ((>=1 & <=5) & 5) 100 a4: ((>=1 & <=5) & 6) 101 a5: ((>=1 & <=5) & 0) 102 a6: ((3 & >=1) & <=5) 103 a7: ((1 & >=1) & <=5) 104 a8: ((5 & >=1) & <=5) 105 a9: ((6 & >=1) & <=5) 106 a10: ((0 & >=1) & <=5) 107 b1: (((>=1 & <=5) & >=1) & <=5) 108 b2: (((>=1 & <=5) & >=1) & <=1) 109 b3: (((>=1 & <=5) & >=5) & <=5) 110 b4: (((>=1 & <=5) & >=2) & <=3) 111 b5: (((>=1 & <=5) & >=3) & <=9) 112 b6: (((>=1 & <=5) & >=5) & <=9) 113 b7: (((>=1 & <=5) & >=6) & <=9) 114 b8: (((>=1 & <=5) & >=1) & <=5) 115 b9: (((>=1 & <=1) & >=1) & <=5) 116 b10: (((>=5 & <=5) & >=1) & <=5) 117 b11: (((>=2 & <=3) & >=1) & <=5) 118 b12: (((>=3 & <=9) & >=1) & <=5) 119 b13: (((>=5 & <=9) & >=1) & <=5) 120 b14: (((>=6 & <=9) & >=1) & <=5) 121 c1: ((int & >=1) & <=5) 122 c2: ((>=1 & <=5) & int) 123 c3: ((string & >=1) & <=5) 124 c4: ((>=1 & <=5) & string) 125 s1: ((>="d" & <="z") & "e") 126 s2: ((>="d" & <="z") & "ee") 127 n1: ((number & >=1) & <=2) 128 n2: ((int & >=1.1) & <=1.3) 129 n3: ((>=1.0 & <=3.0) & 2) 130 n4: ((>=0.0 & <=0.1) & 0.09999) 131 n5: ((>=1 & <=5) & 2.5) 132 } 133 -- out/eval/stats -- 134 Leaks: 0 135 Freed: 36 136 Reused: 34 137 Allocs: 2 138 Retain: 0 139 140 Unifications: 36 141 Conjuncts: 120 142 Disjuncts: 36 143 -- out/evalalpha -- 144 Errors: 145 c3: conflicting values string and >=1 (mismatched types string and number): 146 ./in.cue:34:5 147 ./in.cue:34:14 148 c4: conflicting values string and >=1 (mismatched types string and number): 149 ./in.cue:35:5 150 ./in.cue:35:17 151 a4: invalid value 6 (out of bound <=5): 152 ./in.cue:5:11 153 ./in.cue:5:17 154 a5: invalid value 0 (out of bound >=1): 155 ./in.cue:6:5 156 ./in.cue:6:17 157 a9: invalid value 6 (out of bound <=5): 158 ./in.cue:11:16 159 ./in.cue:11:6 160 a10: invalid value 0 (out of bound >=1): 161 ./in.cue:12:10 162 ./in.cue:12:6 163 b7: incompatible number bounds <=5 and >=6: 164 ./in.cue:21:17 165 ./in.cue:21:11 166 b14: incompatible number bounds <=5 and >=6: 167 ./in.cue:29:24 168 ./in.cue:29:6 169 n2: incompatible integer bounds <=1.3 and >=1.1: 170 ./in.cue:42:19 171 ./in.cue:42:11 172 173 Result: 174 (_|_){ 175 // [eval] 176 a1: (int){ 3 } 177 a2: (int){ 1 } 178 a3: (int){ 5 } 179 a4: (_|_){ 180 // [eval] a4: invalid value 6 (out of bound <=5): 181 // ./in.cue:5:11 182 // ./in.cue:5:17 183 } 184 a5: (_|_){ 185 // [eval] a5: invalid value 0 (out of bound >=1): 186 // ./in.cue:6:5 187 // ./in.cue:6:17 188 } 189 a6: (int){ 3 } 190 a7: (int){ 1 } 191 a8: (int){ 5 } 192 a9: (_|_){ 193 // [eval] a9: invalid value 6 (out of bound <=5): 194 // ./in.cue:11:16 195 // ./in.cue:11:6 196 } 197 a10: (_|_){ 198 // [eval] a10: invalid value 0 (out of bound >=1): 199 // ./in.cue:12:10 200 // ./in.cue:12:6 201 } 202 b1: (number){ &(>=1, <=5) } 203 b2: (number){ 1 } 204 b3: (number){ 5 } 205 b4: (number){ &(>=2, <=3) } 206 b5: (number){ &(>=3, <=5) } 207 b6: (number){ 5 } 208 b7: (_|_){ 209 // [eval] b7: incompatible number bounds <=5 and >=6: 210 // ./in.cue:21:17 211 // ./in.cue:21:11 212 } 213 b8: (number){ &(>=1, <=5) } 214 b9: (number){ 1 } 215 b10: (number){ 5 } 216 b11: (number){ &(>=2, <=3) } 217 b12: (number){ &(>=3, <=5) } 218 b13: (number){ 5 } 219 b14: (_|_){ 220 // [eval] b14: incompatible number bounds <=5 and >=6: 221 // ./in.cue:29:24 222 // ./in.cue:29:6 223 } 224 c1: (int){ &(>=1, <=5, int) } 225 c2: (int){ &(>=1, <=5, int) } 226 c3: (_|_){ 227 // [eval] c3: conflicting values string and >=1 (mismatched types string and number): 228 // ./in.cue:34:5 229 // ./in.cue:34:14 230 } 231 c4: (_|_){ 232 // [eval] c4: conflicting values string and >=1 (mismatched types string and number): 233 // ./in.cue:35:5 234 // ./in.cue:35:17 235 } 236 s1: (string){ "e" } 237 s2: (string){ "ee" } 238 n1: (number){ &(>=1, <=2) } 239 n2: (_|_){ 240 // [eval] n2: incompatible integer bounds <=1.3 and >=1.1: 241 // ./in.cue:42:19 242 // ./in.cue:42:11 243 } 244 n3: (int){ 2 } 245 n4: (float){ 0.09999 } 246 n5: (float){ 2.5 } 247 } 248 -- diff/-out/evalalpha<==>+out/eval -- 249 diff old new 250 --- old 251 +++ new 252 @@ -1,19 +1,10 @@ 253 Errors: 254 -b14: incompatible number bounds <=5 and >=6: 255 - ./in.cue:29:6 256 - ./in.cue:29:24 257 -b7: incompatible number bounds <=5 and >=6: 258 - ./in.cue:21:11 259 - ./in.cue:21:17 260 c3: conflicting values string and >=1 (mismatched types string and number): 261 ./in.cue:34:5 262 ./in.cue:34:14 263 -c4: conflicting values >=1 and string (mismatched types number and string): 264 +c4: conflicting values string and >=1 (mismatched types string and number): 265 ./in.cue:35:5 266 ./in.cue:35:17 267 -n2: incompatible integer bounds <=1.3 and >=1.1: 268 - ./in.cue:42:11 269 - ./in.cue:42:19 270 a4: invalid value 6 (out of bound <=5): 271 ./in.cue:5:11 272 ./in.cue:5:17 273 @@ -26,6 +17,15 @@ 274 a10: invalid value 0 (out of bound >=1): 275 ./in.cue:12:10 276 ./in.cue:12:6 277 +b7: incompatible number bounds <=5 and >=6: 278 + ./in.cue:21:17 279 + ./in.cue:21:11 280 +b14: incompatible number bounds <=5 and >=6: 281 + ./in.cue:29:24 282 + ./in.cue:29:6 283 +n2: incompatible integer bounds <=1.3 and >=1.1: 284 + ./in.cue:42:19 285 + ./in.cue:42:11 286 287 Result: 288 (_|_){ 289 @@ -64,8 +64,8 @@ 290 b6: (number){ 5 } 291 b7: (_|_){ 292 // [eval] b7: incompatible number bounds <=5 and >=6: 293 - // ./in.cue:21:11 294 // ./in.cue:21:17 295 + // ./in.cue:21:11 296 } 297 b8: (number){ &(>=1, <=5) } 298 b9: (number){ 1 } 299 @@ -75,8 +75,8 @@ 300 b13: (number){ 5 } 301 b14: (_|_){ 302 // [eval] b14: incompatible number bounds <=5 and >=6: 303 - // ./in.cue:29:6 304 // ./in.cue:29:24 305 + // ./in.cue:29:6 306 } 307 c1: (int){ &(>=1, <=5, int) } 308 c2: (int){ &(>=1, <=5, int) } 309 @@ -86,7 +86,7 @@ 310 // ./in.cue:34:14 311 } 312 c4: (_|_){ 313 - // [eval] c4: conflicting values >=1 and string (mismatched types number and string): 314 + // [eval] c4: conflicting values string and >=1 (mismatched types string and number): 315 // ./in.cue:35:5 316 // ./in.cue:35:17 317 } 318 @@ -95,8 +95,8 @@ 319 n1: (number){ &(>=1, <=2) } 320 n2: (_|_){ 321 // [eval] n2: incompatible integer bounds <=1.3 and >=1.1: 322 - // ./in.cue:42:11 323 // ./in.cue:42:19 324 + // ./in.cue:42:11 325 } 326 n3: (int){ 2 } 327 n4: (float){ 0.09999 } 328 -- diff/todo/p3 -- 329 Reordering of error messages. 330 -- out/eval -- 331 Errors: 332 b14: incompatible number bounds <=5 and >=6: 333 ./in.cue:29:6 334 ./in.cue:29:24 335 b7: incompatible number bounds <=5 and >=6: 336 ./in.cue:21:11 337 ./in.cue:21:17 338 c3: conflicting values string and >=1 (mismatched types string and number): 339 ./in.cue:34:5 340 ./in.cue:34:14 341 c4: conflicting values >=1 and string (mismatched types number and string): 342 ./in.cue:35:5 343 ./in.cue:35:17 344 n2: incompatible integer bounds <=1.3 and >=1.1: 345 ./in.cue:42:11 346 ./in.cue:42:19 347 a4: invalid value 6 (out of bound <=5): 348 ./in.cue:5:11 349 ./in.cue:5:17 350 a5: invalid value 0 (out of bound >=1): 351 ./in.cue:6:5 352 ./in.cue:6:17 353 a9: invalid value 6 (out of bound <=5): 354 ./in.cue:11:16 355 ./in.cue:11:6 356 a10: invalid value 0 (out of bound >=1): 357 ./in.cue:12:10 358 ./in.cue:12:6 359 360 Result: 361 (_|_){ 362 // [eval] 363 a1: (int){ 3 } 364 a2: (int){ 1 } 365 a3: (int){ 5 } 366 a4: (_|_){ 367 // [eval] a4: invalid value 6 (out of bound <=5): 368 // ./in.cue:5:11 369 // ./in.cue:5:17 370 } 371 a5: (_|_){ 372 // [eval] a5: invalid value 0 (out of bound >=1): 373 // ./in.cue:6:5 374 // ./in.cue:6:17 375 } 376 a6: (int){ 3 } 377 a7: (int){ 1 } 378 a8: (int){ 5 } 379 a9: (_|_){ 380 // [eval] a9: invalid value 6 (out of bound <=5): 381 // ./in.cue:11:16 382 // ./in.cue:11:6 383 } 384 a10: (_|_){ 385 // [eval] a10: invalid value 0 (out of bound >=1): 386 // ./in.cue:12:10 387 // ./in.cue:12:6 388 } 389 b1: (number){ &(>=1, <=5) } 390 b2: (number){ 1 } 391 b3: (number){ 5 } 392 b4: (number){ &(>=2, <=3) } 393 b5: (number){ &(>=3, <=5) } 394 b6: (number){ 5 } 395 b7: (_|_){ 396 // [eval] b7: incompatible number bounds <=5 and >=6: 397 // ./in.cue:21:11 398 // ./in.cue:21:17 399 } 400 b8: (number){ &(>=1, <=5) } 401 b9: (number){ 1 } 402 b10: (number){ 5 } 403 b11: (number){ &(>=2, <=3) } 404 b12: (number){ &(>=3, <=5) } 405 b13: (number){ 5 } 406 b14: (_|_){ 407 // [eval] b14: incompatible number bounds <=5 and >=6: 408 // ./in.cue:29:6 409 // ./in.cue:29:24 410 } 411 c1: (int){ &(>=1, <=5, int) } 412 c2: (int){ &(>=1, <=5, int) } 413 c3: (_|_){ 414 // [eval] c3: conflicting values string and >=1 (mismatched types string and number): 415 // ./in.cue:34:5 416 // ./in.cue:34:14 417 } 418 c4: (_|_){ 419 // [eval] c4: conflicting values >=1 and string (mismatched types number and string): 420 // ./in.cue:35:5 421 // ./in.cue:35:17 422 } 423 s1: (string){ "e" } 424 s2: (string){ "ee" } 425 n1: (number){ &(>=1, <=2) } 426 n2: (_|_){ 427 // [eval] n2: incompatible integer bounds <=1.3 and >=1.1: 428 // ./in.cue:42:11 429 // ./in.cue:42:19 430 } 431 n3: (int){ 2 } 432 n4: (float){ 0.09999 } 433 n5: (float){ 2.5 } 434 }