|
| 1 | +# Tests various patterns of insertion of conjuncts. |
| 2 | +# See https://cuelang.org/issues/2169 |
| 3 | + |
| 4 | +-- a.cue -- |
| 5 | +embeddingDirect: t1: { |
| 6 | + #a: _ |
| 7 | + _ |
| 8 | +} & { |
| 9 | + #a: "s" |
| 10 | + #a |
| 11 | +} |
| 12 | + |
| 13 | +embeddingExpr: t1: { |
| 14 | + #a: _ |
| 15 | + _ |
| 16 | +} & { |
| 17 | + #a: "s" |
| 18 | + [ #a ][0] |
| 19 | +} |
| 20 | + |
| 21 | +unifiedDirect: { |
| 22 | + t1: { |
| 23 | + #a: _ |
| 24 | + _ |
| 25 | + } |
| 26 | + t1: { |
| 27 | + #a |
| 28 | + #a: _ |
| 29 | + } |
| 30 | + t1: { |
| 31 | + _ |
| 32 | + #a: "s" |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | + |
| 37 | +unifiedExpr: { |
| 38 | + t1: { |
| 39 | + #a: _ |
| 40 | + _ |
| 41 | + } |
| 42 | + t1: { |
| 43 | + [ #a ][0] |
| 44 | + #a: _ |
| 45 | + } |
| 46 | + t1: { |
| 47 | + #a: "s" |
| 48 | + _ |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +// These two embeddings both add fields to each other's original source, which |
| 53 | +// then, in turn, needs to be added. |
| 54 | +cross: t1: { |
| 55 | + a: { |
| 56 | + b: {v: 1, a: w: 2} |
| 57 | + // from b.a: {x: 2, b: y: 5} |
| 58 | + } |
| 59 | + b: { |
| 60 | + a: {x: 2, b: y: 5} |
| 61 | + // from a.b: {v: 1, a: v: 2} |
| 62 | + } |
| 63 | + a |
| 64 | + b |
| 65 | +} |
| 66 | + |
| 67 | +-- complex.cue -- |
| 68 | +// Multiple levels of insertion |
| 69 | +recursive: t1: { |
| 70 | + e: {} |
| 71 | + c: d: e: f: 1 |
| 72 | + c.d |
| 73 | + c: d: |
| 74 | + // This part gets embedded within t1, which ends up adding new fields |
| 75 | + // to here, when then again need to be embedded in t1, which then |
| 76 | + // will add more fields to node e. |
| 77 | + c: d: e: g: 1 |
| 78 | +} |
| 79 | + |
| 80 | +-- issue2169.cue -- |
| 81 | +embeddedFunctionalExpr: { |
| 82 | + #fn: { |
| 83 | + #in: _ |
| 84 | + _ |
| 85 | + } & { |
| 86 | + #in: "str" |
| 87 | + |
| 88 | + ({ |
| 89 | + #t: _ |
| 90 | + #t |
| 91 | + } & { |
| 92 | + #t: #in |
| 93 | + _ |
| 94 | + }) + "" |
| 95 | + } |
| 96 | + #fn |
| 97 | +} |
| 98 | +-- out/eval/stats -- |
| 99 | +Leaks: 13 |
| 100 | +Freed: 55 |
| 101 | +Reused: 51 |
| 102 | +Allocs: 17 |
| 103 | +Retain: 36 |
| 104 | + |
| 105 | +Unifications: 68 |
| 106 | +Conjuncts: 225 |
| 107 | +Disjuncts: 87 |
| 108 | +-- out/eval -- |
| 109 | +(struct){ |
| 110 | + embeddingDirect: (struct){ |
| 111 | + t1: (_|_){ |
| 112 | + // [incomplete] embeddingDirect.t1: cannot add field #a: was already used: |
| 113 | + // ./a.cue:5:2 |
| 114 | + #a: (_){ _ } |
| 115 | + } |
| 116 | + } |
| 117 | + embeddingExpr: (struct){ |
| 118 | + t1: (_|_){ |
| 119 | + // [incomplete] embeddingExpr.t1: cannot add field #a: was already used: |
| 120 | + // ./a.cue:13:2 |
| 121 | + #a: (_){ _ } |
| 122 | + } |
| 123 | + } |
| 124 | + unifiedDirect: (struct){ |
| 125 | + t1: (string){ |
| 126 | + "s" |
| 127 | + #a: (string){ "s" } |
| 128 | + } |
| 129 | + } |
| 130 | + unifiedExpr: (struct){ |
| 131 | + t1: (string){ |
| 132 | + "s" |
| 133 | + #a: (string){ "s" } |
| 134 | + } |
| 135 | + } |
| 136 | + cross: (struct){ |
| 137 | + t1: (_|_){ |
| 138 | + // [incomplete] cross.t1: cannot add field a: was already used: |
| 139 | + // ./a.cue:52:13 |
| 140 | + // cross.t1: cannot add field a: was already used: |
| 141 | + // ./a.cue:56:3 |
| 142 | + a: (struct){ |
| 143 | + b: (struct){ |
| 144 | + v: (int){ 1 } |
| 145 | + a: (struct){ |
| 146 | + w: (int){ 2 } |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | + b: (struct){ |
| 151 | + a: (struct){ |
| 152 | + x: (int){ 2 } |
| 153 | + b: (struct){ |
| 154 | + y: (int){ 5 } |
| 155 | + } |
| 156 | + w: (int){ 2 } |
| 157 | + } |
| 158 | + v: (int){ 1 } |
| 159 | + } |
| 160 | + v: (int){ 1 } |
| 161 | + } |
| 162 | + } |
| 163 | + recursive: (struct){ |
| 164 | + t1: (struct){ |
| 165 | + e: (struct){ |
| 166 | + f: (int){ 1 } |
| 167 | + } |
| 168 | + c: (struct){ |
| 169 | + d: (struct){ |
| 170 | + e: (struct){ |
| 171 | + f: (int){ 1 } |
| 172 | + } |
| 173 | + c: (struct){ |
| 174 | + d: (struct){ |
| 175 | + e: (struct){ |
| 176 | + g: (int){ 1 } |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + embeddedFunctionalExpr: (_|_){ |
| 185 | + // [incomplete] embeddedFunctionalExpr: cannot add field #in: was already used: |
| 186 | + // ./issue2169.cue:6:3 |
| 187 | + // embeddedFunctionalExpr: non-concrete value _ in operand to +: |
| 188 | + // ./issue2169.cue:8:3 |
| 189 | + // ./issue2169.cue:8:4 |
| 190 | + #fn: (_|_){ |
| 191 | + // [incomplete] embeddedFunctionalExpr.#fn: cannot add field #in: was already used: |
| 192 | + // ./issue2169.cue:6:3 |
| 193 | + // embeddedFunctionalExpr.#fn: non-concrete value _ in operand to +: |
| 194 | + // ./issue2169.cue:8:3 |
| 195 | + // ./issue2169.cue:8:4 |
| 196 | + #in: (_){ _ } |
| 197 | + } |
| 198 | + #in: (_){ _ } |
| 199 | + } |
| 200 | +} |
| 201 | +-- out/compile -- |
| 202 | +--- a.cue |
| 203 | +{ |
| 204 | + embeddingDirect: { |
| 205 | + t1: ({ |
| 206 | + #a: _ |
| 207 | + _ |
| 208 | + } & { |
| 209 | + #a: "s" |
| 210 | + 〈0;#a〉 |
| 211 | + }) |
| 212 | + } |
| 213 | + embeddingExpr: { |
| 214 | + t1: ({ |
| 215 | + #a: _ |
| 216 | + _ |
| 217 | + } & { |
| 218 | + #a: "s" |
| 219 | + [ |
| 220 | + 〈1;#a〉, |
| 221 | + ][0] |
| 222 | + }) |
| 223 | + } |
| 224 | + unifiedDirect: { |
| 225 | + t1: { |
| 226 | + #a: _ |
| 227 | + _ |
| 228 | + } |
| 229 | + t1: { |
| 230 | + 〈0;#a〉 |
| 231 | + #a: _ |
| 232 | + } |
| 233 | + t1: { |
| 234 | + _ |
| 235 | + #a: "s" |
| 236 | + } |
| 237 | + } |
| 238 | + unifiedExpr: { |
| 239 | + t1: { |
| 240 | + #a: _ |
| 241 | + _ |
| 242 | + } |
| 243 | + t1: { |
| 244 | + [ |
| 245 | + 〈1;#a〉, |
| 246 | + ][0] |
| 247 | + #a: _ |
| 248 | + } |
| 249 | + t1: { |
| 250 | + #a: "s" |
| 251 | + _ |
| 252 | + } |
| 253 | + } |
| 254 | + cross: { |
| 255 | + t1: { |
| 256 | + a: { |
| 257 | + b: { |
| 258 | + v: 1 |
| 259 | + a: { |
| 260 | + w: 2 |
| 261 | + } |
| 262 | + } |
| 263 | + } |
| 264 | + b: { |
| 265 | + a: { |
| 266 | + x: 2 |
| 267 | + b: { |
| 268 | + y: 5 |
| 269 | + } |
| 270 | + } |
| 271 | + } |
| 272 | + 〈0;a〉 |
| 273 | + 〈0;b〉 |
| 274 | + } |
| 275 | + } |
| 276 | +} |
| 277 | +--- complex.cue |
| 278 | +{ |
| 279 | + recursive: { |
| 280 | + t1: { |
| 281 | + e: {} |
| 282 | + c: { |
| 283 | + d: { |
| 284 | + e: { |
| 285 | + f: 1 |
| 286 | + } |
| 287 | + } |
| 288 | + } |
| 289 | + 〈0;c〉.d |
| 290 | + c: { |
| 291 | + d: { |
| 292 | + c: { |
| 293 | + d: { |
| 294 | + e: { |
| 295 | + g: 1 |
| 296 | + } |
| 297 | + } |
| 298 | + } |
| 299 | + } |
| 300 | + } |
| 301 | + } |
| 302 | + } |
| 303 | +} |
| 304 | +--- issue2169.cue |
| 305 | +{ |
| 306 | + embeddedFunctionalExpr: { |
| 307 | + #fn: ({ |
| 308 | + #in: _ |
| 309 | + _ |
| 310 | + } & { |
| 311 | + #in: "str" |
| 312 | + (({ |
| 313 | + #t: _ |
| 314 | + 〈0;#t〉 |
| 315 | + } & { |
| 316 | + #t: 〈1;#in〉 |
| 317 | + _ |
| 318 | + }) + "") |
| 319 | + }) |
| 320 | + 〈0;#fn〉 |
| 321 | + } |
| 322 | +} |
0 commit comments