this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: add tests for Issue 3925 and 3905

We only include the smaller reproducer created by
mvdan. We did verify the larger issue was fixed.

Issue #3925
Issue #3905

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I78efa6e4234d0d9c600ae28d307f8ba0a98a9f85
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1215092
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+548 -34
+288
cue/testdata/eval/issue3905.txtar
··· 1 + -- in.cue -- 2 + issue3905: reduced: { 3 + #Schema: { 4 + params: name: string | *"foo" 5 + 6 + result: (params.name): "bar" 7 + } 8 + 9 + (#Schema).result 10 + } 11 + issue3905: full: { 12 + #ReferenceGrantBuilder: { 13 + parameters: { 14 + namespace: string 15 + gatewayNamespace: string | *"foo" 16 + } 17 + 18 + referenceGrant: (parameters.gatewayNamespace): #ReferenceGrant & { 19 + metadata: name: parameters.gatewayNamespace 20 + metadata: namespace: parameters.namespace 21 + } 22 + } 23 + 24 + (#ReferenceGrantBuilder & { 25 + parameters: namespace: "foo" 26 + }).referenceGrant 27 + 28 + #ReferenceGrant: { 29 + apiVersion: "gateway.networking.k8s.io/v1beta1" 30 + kind: "ReferenceGrant" 31 + metadata!: { 32 + name!: string 33 + namespace!: string 34 + labels?: { 35 + [string]: string 36 + } 37 + annotations?: { 38 + [string]: string 39 + } 40 + } 41 + } 42 + } 43 + -- out/eval/stats -- 44 + Leaks: 3 45 + Freed: 57 46 + Reused: 47 47 + Allocs: 13 48 + Retain: 26 49 + 50 + Unifications: 48 51 + Conjuncts: 93 52 + Disjuncts: 81 53 + -- out/evalalpha -- 54 + (struct){ 55 + issue3905: (struct){ 56 + reduced: (_|_){ 57 + // [incomplete] issue3905.reduced: key value of dynamic field must be concrete, found _|_(cycle error): 58 + // ./in.cue:5:12 59 + #Schema: (#struct){ 60 + params: (#struct){ 61 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 62 + } 63 + result: (#struct){ 64 + foo: (string){ "bar" } 65 + } 66 + } 67 + } 68 + full: (_|_){ 69 + // [incomplete] issue3905.full: key value of dynamic field must be concrete, found _|_(cycle error): 70 + // ./in.cue:17:20 71 + #ReferenceGrantBuilder: (#struct){ 72 + parameters: (#struct){ 73 + namespace: (string){ string } 74 + gatewayNamespace: (string){ |(*(string){ "foo" }, (string){ string }) } 75 + } 76 + referenceGrant: (#struct){ 77 + foo: (#struct){ 78 + metadata: (#struct){ 79 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 80 + namespace: (string){ string } 81 + labels?: (#struct){ 82 + } 83 + annotations?: (#struct){ 84 + } 85 + } 86 + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 87 + kind: (string){ "ReferenceGrant" } 88 + } 89 + } 90 + } 91 + #ReferenceGrant: (#struct){ 92 + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 93 + kind: (string){ "ReferenceGrant" } 94 + metadata!: (#struct){ 95 + name!: (string){ string } 96 + namespace!: (string){ string } 97 + labels?: (#struct){ 98 + } 99 + annotations?: (#struct){ 100 + } 101 + } 102 + } 103 + } 104 + } 105 + } 106 + -- diff/-out/evalalpha<==>+out/eval -- 107 + diff old new 108 + --- old 109 + +++ new 110 + @@ -1,6 +1,8 @@ 111 + (struct){ 112 + issue3905: (struct){ 113 + - reduced: (#struct){ 114 + + reduced: (_|_){ 115 + + // [incomplete] issue3905.reduced: key value of dynamic field must be concrete, found _|_(cycle error): 116 + + // ./in.cue:5:12 117 + #Schema: (#struct){ 118 + params: (#struct){ 119 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 120 + @@ -9,9 +11,10 @@ 121 + foo: (string){ "bar" } 122 + } 123 + } 124 + - foo: (string){ "bar" } 125 + - } 126 + - full: (struct){ 127 + + } 128 + + full: (_|_){ 129 + + // [incomplete] issue3905.full: key value of dynamic field must be concrete, found _|_(cycle error): 130 + + // ./in.cue:17:20 131 + #ReferenceGrantBuilder: (#struct){ 132 + parameters: (#struct){ 133 + namespace: (string){ string } 134 + @@ -19,8 +22,6 @@ 135 + } 136 + referenceGrant: (#struct){ 137 + foo: (#struct){ 138 + - apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 139 + - kind: (string){ "ReferenceGrant" } 140 + metadata: (#struct){ 141 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 142 + namespace: (string){ string } 143 + @@ -29,6 +30,8 @@ 144 + annotations?: (#struct){ 145 + } 146 + } 147 + + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 148 + + kind: (string){ "ReferenceGrant" } 149 + } 150 + } 151 + } 152 + @@ -44,18 +47,6 @@ 153 + } 154 + } 155 + } 156 + - foo: (#struct){ 157 + - apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 158 + - kind: (string){ "ReferenceGrant" } 159 + - metadata: (#struct){ 160 + - name: (string){ |(*(string){ "foo" }, (string){ string }) } 161 + - namespace: (string){ "foo" } 162 + - labels?: (#struct){ 163 + - } 164 + - annotations?: (#struct){ 165 + - } 166 + - } 167 + - } 168 + } 169 + } 170 + } 171 + -- out/eval -- 172 + (struct){ 173 + issue3905: (struct){ 174 + reduced: (#struct){ 175 + #Schema: (#struct){ 176 + params: (#struct){ 177 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 178 + } 179 + result: (#struct){ 180 + foo: (string){ "bar" } 181 + } 182 + } 183 + foo: (string){ "bar" } 184 + } 185 + full: (struct){ 186 + #ReferenceGrantBuilder: (#struct){ 187 + parameters: (#struct){ 188 + namespace: (string){ string } 189 + gatewayNamespace: (string){ |(*(string){ "foo" }, (string){ string }) } 190 + } 191 + referenceGrant: (#struct){ 192 + foo: (#struct){ 193 + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 194 + kind: (string){ "ReferenceGrant" } 195 + metadata: (#struct){ 196 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 197 + namespace: (string){ string } 198 + labels?: (#struct){ 199 + } 200 + annotations?: (#struct){ 201 + } 202 + } 203 + } 204 + } 205 + } 206 + #ReferenceGrant: (#struct){ 207 + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 208 + kind: (string){ "ReferenceGrant" } 209 + metadata!: (#struct){ 210 + name!: (string){ string } 211 + namespace!: (string){ string } 212 + labels?: (#struct){ 213 + } 214 + annotations?: (#struct){ 215 + } 216 + } 217 + } 218 + foo: (#struct){ 219 + apiVersion: (string){ "gateway.networking.k8s.io/v1beta1" } 220 + kind: (string){ "ReferenceGrant" } 221 + metadata: (#struct){ 222 + name: (string){ |(*(string){ "foo" }, (string){ string }) } 223 + namespace: (string){ "foo" } 224 + labels?: (#struct){ 225 + } 226 + annotations?: (#struct){ 227 + } 228 + } 229 + } 230 + } 231 + } 232 + } 233 + -- out/compile -- 234 + --- in.cue 235 + { 236 + issue3905: { 237 + reduced: { 238 + #Schema: { 239 + params: { 240 + name: (string|*"foo") 241 + } 242 + result: { 243 + 〈1;params〉.name: "bar" 244 + } 245 + } 246 + 〈0;#Schema〉.result 247 + } 248 + } 249 + issue3905: { 250 + full: { 251 + #ReferenceGrantBuilder: { 252 + parameters: { 253 + namespace: string 254 + gatewayNamespace: (string|*"foo") 255 + } 256 + referenceGrant: { 257 + 〈1;parameters〉.gatewayNamespace: (〈2;#ReferenceGrant〉 & { 258 + metadata: { 259 + name: 〈3;parameters〉.gatewayNamespace 260 + } 261 + metadata: { 262 + namespace: 〈3;parameters〉.namespace 263 + } 264 + }) 265 + } 266 + } 267 + (〈0;#ReferenceGrantBuilder〉 & { 268 + parameters: { 269 + namespace: "foo" 270 + } 271 + }).referenceGrant 272 + #ReferenceGrant: { 273 + apiVersion: "gateway.networking.k8s.io/v1beta1" 274 + kind: "ReferenceGrant" 275 + metadata!: { 276 + name!: string 277 + namespace!: string 278 + labels?: { 279 + [string]: string 280 + } 281 + annotations?: { 282 + [string]: string 283 + } 284 + } 285 + } 286 + } 287 + } 288 + }
+260 -34
cue/testdata/eval/v0.7.txtar
··· 214 214 }.out 215 215 } 216 216 217 + -- chained.cue -- 218 + import "encoding/yaml" 219 + 220 + issue3925: reduced: { 221 + out: yaml.Marshal(in.b.actual) 222 + in: { 223 + a: "actual" 224 + a: "actual" | "other" 225 + b: (a): c: "str" 226 + } 227 + } 228 + issue3925: full: { 229 + for name, _ in _inputs { 230 + out: (name): early: "early value" 231 + } 232 + _inputs: input1: { 233 + name: "actual" 234 + config: (name): one: "one value" 235 + } 236 + _inputs: [_]: { 237 + name: "actual" | "other" 238 + } 239 + for name, input in _inputs { 240 + out: (name): lateYAML: yaml.Marshal(input.config[input.name]) 241 + } 242 + } 217 243 -- out/eval/stats -- 218 244 Leaks: 4 219 - Freed: 285 220 - Reused: 273 245 + Freed: 308 246 + Reused: 296 221 247 Allocs: 16 222 - Retain: 170 248 + Retain: 183 223 249 224 - Unifications: 269 225 - Conjuncts: 1619 226 - Disjuncts: 436 250 + Unifications: 288 251 + Conjuncts: 1650 252 + Disjuncts: 472 227 253 -- out/eval -- 228 254 Errors: 229 255 definition.t0.err.d1.env.c: field not allowed: ··· 259 285 s3: (bool){ true } 260 286 s5: (string){ "dd" } 261 287 s6: (string){ "dd" } 288 + } 289 + } 290 + } 291 + issue3925: (struct){ 292 + reduced: (struct){ 293 + out: (string){ "c: str\n" } 294 + in: (struct){ 295 + a: (string){ "actual" } 296 + b: (struct){ 297 + actual: (struct){ 298 + c: (string){ "str" } 299 + } 300 + } 301 + } 302 + } 303 + full: (struct){ 304 + out: (struct){ 305 + input1: (struct){ 306 + early: (string){ "early value" } 307 + lateYAML: (string){ "one: one value\n" } 308 + } 309 + } 310 + _inputs: (struct){ 311 + input1: (struct){ 312 + name: (string){ "actual" } 313 + config: (struct){ 314 + actual: (struct){ 315 + one: (string){ "one value" } 316 + } 317 + } 318 + } 262 319 } 263 320 } 264 321 } ··· 683 740 } 684 741 } 685 742 -- out/evalalpha/stats -- 686 - Leaks: 265 743 + Leaks: 292 687 744 Freed: 0 688 745 Reused: 0 689 - Allocs: 265 746 + Allocs: 292 690 747 Retain: 0 691 748 692 - Unifications: 256 693 - Conjuncts: 568 694 - Disjuncts: 6 749 + Unifications: 277 750 + Conjuncts: 605 751 + Disjuncts: 12 695 752 696 753 CloseIDElems: 38 697 - NumCloseIDs: 82 754 + NumCloseIDs: 83 698 755 -- out/evalalpha -- 699 756 Errors: 700 757 definition.t0.err.d1.env.c: field not allowed: 701 758 ./definition.cue:3:11 702 759 definition.t1.err.a.c: field not allowed: 703 760 ./definition.cue:9:5 761 + issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 762 + ./chained.cue:8:11 763 + issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 764 + ./chained.cue:17:19 704 765 705 766 Result: 706 767 (_|_){ ··· 717 778 s3: (bool){ true } 718 779 s5: (string){ "dd" } 719 780 s6: (string){ "dd" } 781 + } 782 + } 783 + } 784 + issue3925: (_|_){ 785 + // [eval] 786 + reduced: (_|_){ 787 + // [eval] 788 + out: (_|_){ 789 + // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 790 + // ./chained.cue:8:11 791 + } 792 + in: (_|_){ 793 + // [eval] 794 + a: (string){ "actual" } 795 + b: (_|_){ 796 + // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 797 + // ./chained.cue:8:11 798 + } 799 + } 800 + } 801 + full: (_|_){ 802 + // [eval] 803 + out: (_|_){ 804 + // [eval] 805 + input1: (_|_){ 806 + // [eval] 807 + early: (string){ "early value" } 808 + lateYAML: (_|_){ 809 + // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 810 + // ./chained.cue:17:19 811 + } 812 + } 813 + } 814 + _inputs: (_|_){ 815 + // [eval] 816 + input1: (_|_){ 817 + // [eval] 818 + name: (string){ "actual" } 819 + config: (_|_){ 820 + // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 821 + // ./chained.cue:17:19 822 + } 823 + } 720 824 } 721 825 } 722 826 } ··· 1109 1213 +++ new 1110 1214 @@ -1,9 +1,12 @@ 1111 1215 -Leaks: 4 1112 - -Freed: 285 1113 - -Reused: 273 1216 + -Freed: 308 1217 + -Reused: 296 1114 1218 -Allocs: 16 1115 - -Retain: 170 1219 + -Retain: 183 1116 1220 - 1117 - -Unifications: 269 1118 - -Conjuncts: 1619 1119 - -Disjuncts: 436 1120 - +Leaks: 265 1221 + -Unifications: 288 1222 + -Conjuncts: 1650 1223 + -Disjuncts: 472 1224 + +Leaks: 292 1121 1225 +Freed: 0 1122 1226 +Reused: 0 1123 - +Allocs: 265 1227 + +Allocs: 292 1124 1228 +Retain: 0 1125 1229 + 1126 - +Unifications: 256 1127 - +Conjuncts: 568 1128 - +Disjuncts: 6 1230 + +Unifications: 277 1231 + +Conjuncts: 605 1232 + +Disjuncts: 12 1129 1233 + 1130 1234 +CloseIDElems: 38 1131 - +NumCloseIDs: 82 1235 + +NumCloseIDs: 83 1132 1236 -- diff/-out/evalalpha<==>+out/eval -- 1133 1237 diff old new 1134 1238 --- old 1135 1239 +++ new 1136 - @@ -1,16 +1,8 @@ 1240 + @@ -1,16 +1,12 @@ 1137 1241 Errors: 1138 1242 definition.t0.err.d1.env.c: field not allowed: 1139 1243 - ./definition.cue:2:12 ··· 1147 1251 -mutual.t4.ok.p0.z: cannot add to field c 1148 1252 -mutual.t4.ok.p4.z: cannot add to field b 1149 1253 -mutual.t4.ok.p4.z: cannot add to field c 1254 + +issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 1255 + + ./chained.cue:8:11 1256 + +issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 1257 + + ./chained.cue:17:19 1150 1258 1151 1259 Result: 1152 1260 (_|_){ 1153 - @@ -19,12 +11,7 @@ 1261 + @@ -19,12 +15,7 @@ 1154 1262 t1: (struct){ 1155 1263 ok: (struct){ 1156 1264 s3: (string){ strings.ContainsAny("dd") } ··· 1164 1272 } 1165 1273 } 1166 1274 t2: (struct){ 1167 - @@ -61,9 +48,7 @@ 1275 + @@ -35,32 +26,44 @@ 1276 + } 1277 + } 1278 + } 1279 + - issue3925: (struct){ 1280 + - reduced: (struct){ 1281 + - out: (string){ "c: str\n" } 1282 + - in: (struct){ 1283 + + issue3925: (_|_){ 1284 + + // [eval] 1285 + + reduced: (_|_){ 1286 + + // [eval] 1287 + + out: (_|_){ 1288 + + // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 1289 + + // ./chained.cue:8:11 1290 + + } 1291 + + in: (_|_){ 1292 + + // [eval] 1293 + a: (string){ "actual" } 1294 + - b: (struct){ 1295 + - actual: (struct){ 1296 + - c: (string){ "str" } 1297 + - } 1298 + - } 1299 + - } 1300 + - } 1301 + - full: (struct){ 1302 + - out: (struct){ 1303 + - input1: (struct){ 1304 + + b: (_|_){ 1305 + + // [eval] issue3925.reduced.in.b.actual: adding field c not allowed as field set was already referenced: 1306 + + // ./chained.cue:8:11 1307 + + } 1308 + + } 1309 + + } 1310 + + full: (_|_){ 1311 + + // [eval] 1312 + + out: (_|_){ 1313 + + // [eval] 1314 + + input1: (_|_){ 1315 + + // [eval] 1316 + early: (string){ "early value" } 1317 + - lateYAML: (string){ "one: one value\n" } 1318 + - } 1319 + - } 1320 + - _inputs: (struct){ 1321 + - input1: (struct){ 1322 + + lateYAML: (_|_){ 1323 + + // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 1324 + + // ./chained.cue:17:19 1325 + + } 1326 + + } 1327 + + } 1328 + + _inputs: (_|_){ 1329 + + // [eval] 1330 + + input1: (_|_){ 1331 + + // [eval] 1332 + name: (string){ "actual" } 1333 + - config: (struct){ 1334 + - actual: (struct){ 1335 + - one: (string){ "one value" } 1336 + - } 1337 + + config: (_|_){ 1338 + + // [eval] issue3925.full._inputs.input1.config.actual: adding field one not allowed as field set was already referenced: 1339 + + // ./chained.cue:17:19 1340 + } 1341 + } 1342 + } 1343 + @@ -92,9 +95,7 @@ 1168 1344 // [eval] 1169 1345 c: (_|_){ 1170 1346 // [eval] definition.t0.err.d1.env.c: field not allowed: ··· 1174 1350 } 1175 1351 } 1176 1352 } 1177 - @@ -77,9 +62,7 @@ 1353 + @@ -108,9 +109,7 @@ 1178 1354 // [eval] 1179 1355 c: (_|_){ 1180 1356 // [eval] definition.t1.err.a.c: field not allowed: ··· 1184 1360 } 1185 1361 } 1186 1362 #A: (#struct){ 1187 - @@ -93,32 +76,32 @@ 1363 + @@ -124,32 +123,32 @@ 1188 1364 a: (int){ int } 1189 1365 } 1190 1366 x: (#struct){ ··· 1243 1419 } 1244 1420 #A: (#struct){ 1245 1421 a: (int){ int } 1246 - @@ -141,14 +124,7 @@ 1422 + @@ -172,14 +171,7 @@ 1247 1423 } 1248 1424 t2: (struct){ 1249 1425 ok: (struct){ ··· 1259 1435 #X: (#struct){ 1260 1436 a: (#struct){ 1261 1437 b: (#struct){ 1262 - @@ -202,8 +178,7 @@ 1438 + @@ -233,8 +225,7 @@ 1263 1439 } 1264 1440 } 1265 1441 } ··· 1269 1445 t0: (struct){ 1270 1446 ok: (struct){ 1271 1447 c: (struct){ 1272 - @@ -270,135 +245,116 @@ 1448 + @@ -301,135 +292,116 @@ 1273 1449 } 1274 1450 } 1275 1451 } ··· 1515 1691 } 1516 1692 } 1517 1693 p5: (struct){ 1518 - @@ -407,23 +363,20 @@ 1694 + @@ -438,23 +410,20 @@ 1519 1695 d: (struct){ 1520 1696 b: (int){ 2 } 1521 1697 } ··· 1553 1729 } 1554 1730 } 1555 1731 check: (struct){ 1556 - @@ -445,10 +398,7 @@ 1732 + @@ -476,10 +445,7 @@ 1557 1733 b: (int){ 2 } 1558 1734 } 1559 1735 y: (struct){ ··· 1587 1763 s3: 〈import;strings〉.ContainsAny(〈0;s5〉, "dd") 1588 1764 s5: 〈0;s6〉 1589 1765 s6: "dd" 1766 + } 1767 + } 1768 + } 1769 + } 1770 + --- chained.cue 1771 + { 1772 + issue3925: { 1773 + reduced: { 1774 + out: 〈import;"encoding/yaml"〉.Marshal(〈0;in〉.b.actual) 1775 + in: { 1776 + a: "actual" 1777 + a: ("actual"|"other") 1778 + b: { 1779 + 〈1;a〉: { 1780 + c: "str" 1781 + } 1782 + } 1783 + } 1784 + } 1785 + } 1786 + issue3925: { 1787 + full: { 1788 + for name, _ in 〈0;_inputs〉 { 1789 + out: { 1790 + 〈2;name〉: { 1791 + early: "early value" 1792 + } 1793 + } 1794 + } 1795 + _inputs: { 1796 + input1: { 1797 + name: "actual" 1798 + config: { 1799 + 〈1;name〉: { 1800 + one: "one value" 1801 + } 1802 + } 1803 + } 1804 + } 1805 + _inputs: { 1806 + [_]: { 1807 + name: ("actual"|"other") 1808 + } 1809 + } 1810 + for name, input in 〈0;_inputs〉 { 1811 + out: { 1812 + 〈2;name〉: { 1813 + lateYAML: 〈import;"encoding/yaml"〉.Marshal(〈3;input〉.config[〈3;input〉.name]) 1814 + } 1815 + } 1590 1816 } 1591 1817 } 1592 1818 }