cuelang.org/go@v0.13.0/cue/testdata/basicrewrite/010_lists.txtar (about) 1 #name: lists 2 #evalPartial 3 -- in.cue -- 4 list: [1, 2, 3] 5 index: [1, 2, 3][1] 6 unify: [1, 2, 3] & [_, 2, 3] 7 e: [] & 4 8 e2: [3]["d"] 9 e3: [3][-1] 10 e4: [1, 2, ...>=4 & <=5] & [1, 2, 4, 8] 11 e5: [1, 2, 4, 8] & [1, 2, ...>=4 & <=5] 12 -- out/def -- 13 list: [1, 2, 3] 14 index: 2 15 unify: [1, 2, 3] 16 e: _|_ // conflicting values [] and 4 (mismatched types list and int) 17 e2: _|_ // invalid list index "d" (type string) 18 e3: _|_ // invalid list index -1 (index must be non-negative) 19 e4: [1, 2, 4, _|_, // invalid value 8 (out of bound <=5) 20 ] 21 e5: [1, 2, 4, _|_, // invalid value 8 (out of bound <=5) 22 ] 23 -- out/legacy-debug -- 24 <0>{list: [1,2,3], index: 2, unify: [1,2,3], e: _|_(([] & 4):conflicting values [] and 4 (mismatched types list and int)), e2: _|_("d":invalid list index "d" (type string)), e3: _|_(-1:invalid list index -1 (index must be non-negative)), e4: [1,2,4,_|_((<=5 & 8):invalid value 8 (out of bound <=5))], e5: [1,2,4,_|_((<=5 & 8):invalid value 8 (out of bound <=5))]} 25 -- out/compile -- 26 --- in.cue 27 { 28 list: [ 29 1, 30 2, 31 3, 32 ] 33 index: [ 34 1, 35 2, 36 3, 37 ][1] 38 unify: ([ 39 1, 40 2, 41 3, 42 ] & [ 43 _, 44 2, 45 3, 46 ]) 47 e: ([] & 4) 48 e2: [ 49 3, 50 ]["d"] 51 e3: [ 52 3, 53 ][-1] 54 e4: ([ 55 1, 56 2, 57 ...(>=4 & <=5), 58 ] & [ 59 1, 60 2, 61 4, 62 8, 63 ]) 64 e5: ([ 65 1, 66 2, 67 4, 68 8, 69 ] & [ 70 1, 71 2, 72 ...(>=4 & <=5), 73 ]) 74 } 75 -- out/eval/stats -- 76 Leaks: 4 77 Freed: 23 78 Reused: 20 79 Allocs: 7 80 Retain: 4 81 82 Unifications: 27 83 Conjuncts: 46 84 Disjuncts: 26 85 -- out/evalalpha -- 86 Errors: 87 e: conflicting values [] and 4 (mismatched types list and int): 88 ./in.cue:4:8 89 ./in.cue:4:13 90 e2: undefined field: d: 91 ./in.cue:5:12 92 e3: invalid index -1 (index must be non-negative): 93 ./in.cue:6:8 94 ./in.cue:6:12 95 e4.3: invalid value 8 (out of bound <=5): 96 ./in.cue:7:24 97 ./in.cue:7:41 98 e5.3: invalid value 8 (out of bound <=5): 99 ./in.cue:8:39 100 ./in.cue:8:18 101 102 Result: 103 (_|_){ 104 // [eval] 105 list: (#list){ 106 0: (int){ 1 } 107 1: (int){ 2 } 108 2: (int){ 3 } 109 } 110 index: (int){ 2 } 111 unify: (#list){ 112 0: (int){ 1 } 113 1: (int){ 2 } 114 2: (int){ 3 } 115 } 116 e: (_|_){ 117 // [eval] e: conflicting values [] and 4 (mismatched types list and int): 118 // ./in.cue:4:8 119 // ./in.cue:4:13 120 } 121 e2: (_|_){ 122 // [eval] e2: undefined field: d: 123 // ./in.cue:5:12 124 } 125 e3: (_|_){ 126 // [eval] e3: invalid index -1 (index must be non-negative): 127 // ./in.cue:6:8 128 // ./in.cue:6:12 129 } 130 e4: (_|_){ 131 // [eval] 132 0: (int){ 1 } 133 1: (int){ 2 } 134 2: (int){ 4 } 135 3: (_|_){ 136 // [eval] e4.3: invalid value 8 (out of bound <=5): 137 // ./in.cue:7:24 138 // ./in.cue:7:41 139 } 140 } 141 e5: (_|_){ 142 // [eval] 143 0: (int){ 1 } 144 1: (int){ 2 } 145 2: (int){ 4 } 146 3: (_|_){ 147 // [eval] e5.3: invalid value 8 (out of bound <=5): 148 // ./in.cue:8:39 149 // ./in.cue:8:18 150 } 151 } 152 } 153 -- diff/-out/evalalpha<==>+out/eval -- 154 diff old new 155 --- old 156 +++ new 157 @@ -1,8 +1,8 @@ 158 Errors: 159 -e: conflicting values 4 and [] (mismatched types int and list): 160 +e: conflicting values [] and 4 (mismatched types list and int): 161 ./in.cue:4:8 162 ./in.cue:4:13 163 -e2: invalid list index d (type string): 164 +e2: undefined field: d: 165 ./in.cue:5:12 166 e3: invalid index -1 (index must be non-negative): 167 ./in.cue:6:8 168 @@ -29,12 +29,12 @@ 169 2: (int){ 3 } 170 } 171 e: (_|_){ 172 - // [eval] e: conflicting values 4 and [] (mismatched types int and list): 173 + // [eval] e: conflicting values [] and 4 (mismatched types list and int): 174 // ./in.cue:4:8 175 // ./in.cue:4:13 176 } 177 e2: (_|_){ 178 - // [eval] e2: invalid list index d (type string): 179 + // [eval] e2: undefined field: d: 180 // ./in.cue:5:12 181 } 182 e3: (_|_){ 183 -- diff/todo/p2 -- 184 error: more precise message 185 -- out/eval -- 186 Errors: 187 e: conflicting values 4 and [] (mismatched types int and list): 188 ./in.cue:4:8 189 ./in.cue:4:13 190 e2: invalid list index d (type string): 191 ./in.cue:5:12 192 e3: invalid index -1 (index must be non-negative): 193 ./in.cue:6:8 194 ./in.cue:6:12 195 e4.3: invalid value 8 (out of bound <=5): 196 ./in.cue:7:24 197 ./in.cue:7:41 198 e5.3: invalid value 8 (out of bound <=5): 199 ./in.cue:8:39 200 ./in.cue:8:18 201 202 Result: 203 (_|_){ 204 // [eval] 205 list: (#list){ 206 0: (int){ 1 } 207 1: (int){ 2 } 208 2: (int){ 3 } 209 } 210 index: (int){ 2 } 211 unify: (#list){ 212 0: (int){ 1 } 213 1: (int){ 2 } 214 2: (int){ 3 } 215 } 216 e: (_|_){ 217 // [eval] e: conflicting values 4 and [] (mismatched types int and list): 218 // ./in.cue:4:8 219 // ./in.cue:4:13 220 } 221 e2: (_|_){ 222 // [eval] e2: invalid list index d (type string): 223 // ./in.cue:5:12 224 } 225 e3: (_|_){ 226 // [eval] e3: invalid index -1 (index must be non-negative): 227 // ./in.cue:6:8 228 // ./in.cue:6:12 229 } 230 e4: (_|_){ 231 // [eval] 232 0: (int){ 1 } 233 1: (int){ 2 } 234 2: (int){ 4 } 235 3: (_|_){ 236 // [eval] e4.3: invalid value 8 (out of bound <=5): 237 // ./in.cue:7:24 238 // ./in.cue:7:41 239 } 240 } 241 e5: (_|_){ 242 // [eval] 243 0: (int){ 1 } 244 1: (int){ 2 } 245 2: (int){ 4 } 246 3: (_|_){ 247 // [eval] e5.3: invalid value 8 (out of bound <=5): 248 // ./in.cue:8:39 249 // ./in.cue:8:18 250 } 251 } 252 }