Skip to content

Commit b3006ad

Browse files
committed
cue: add regression test for a disjunction fix in evalv3
https://cuelang.org/issue/1417 describes a case where we expect a concrete result but the old evaluator would result in an error due to issues with the old disjunction algorithm. Luckily, CUE_EXPERIMENT=evalv3's new disjunction algorithm already handles this case properly. Add a regression test so that we can mark the issue as closed. Closes #1417. Signed-off-by: Daniel Martí <[email protected]> Change-Id: If0ae2855a27a12413302846a74ceb41bbf68941a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194556 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 84fe1b9 commit b3006ad

File tree

1 file changed

+118
-24
lines changed

1 file changed

+118
-24
lines changed

cue/testdata/disjunctions/elimination.txtar

Lines changed: 118 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ issue2263: full: {
486486
value: number
487487
}
488488
}
489+
-- issue1417.cue --
490+
#ID: !~"^a" | =~"^ab$" | =~"^aB$"
491+
#ID: =~"^a" | !~"[A-Z]"
492+
ids: [...#ID] & ["xyz", "ab", "aB"]
489493
-- out/evalalpha --
490494
(struct){
491495
disambiguateClosed: (struct){
@@ -909,6 +913,12 @@ issue2263: full: {
909913
}
910914
}
911915
}
916+
#ID: (string){ |((string){ &(!~"^a", =~"^a") }, (string){ &(!~"^a", !~"[A-Z]") }, (string){ &(=~"^ab$", =~"^a") }, (string){ &(=~"^ab$", !~"[A-Z]") }, (string){ &(=~"^aB$", =~"^a") }, (string){ &(=~"^aB$", !~"[A-Z]") }) }
917+
ids: (#list){
918+
0: (string){ "xyz" }
919+
1: (string){ "ab" }
920+
2: (string){ "aB" }
921+
}
912922
issue2209: (struct){
913923
simplified: (struct){
914924
t1: (struct){
@@ -1400,8 +1410,9 @@ issue2263: full: {
14001410
diff old new
14011411
--- old
14021412
+++ new
1403-
@@ -1,36 +1,4 @@
1413+
@@ -1,49 +1,4 @@
14041414
-Errors:
1415+
-ids.2: 2 errors in empty disjunction:
14051416
-issue2209.full.Bar.resource.spec: 6 errors in empty disjunction:
14061417
-issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction:
14071418
-issue2209.full.Bar.resource.spec.minBar: conflicting values null and int (mismatched types null and int):
@@ -1426,6 +1437,18 @@ diff old new
14261437
- ./issue2209full.cue:83:16
14271438
- ./issue2209full.cue:92:13
14281439
- ./issue2209full.cue:105:20
1440+
-ids.1: invalid value "ab" (out of bound !~"^a"):
1441+
- ./issue1417.cue:1:6
1442+
- ./issue1417.cue:3:10
1443+
- ./issue1417.cue:3:25
1444+
-ids.2: invalid value "aB" (out of bound !~"^a"):
1445+
- ./issue1417.cue:1:6
1446+
- ./issue1417.cue:3:10
1447+
- ./issue1417.cue:3:31
1448+
-ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
1449+
- ./issue1417.cue:2:15
1450+
- ./issue1417.cue:3:10
1451+
- ./issue1417.cue:3:31
14291452
-issue2209.simplified.t3.BAZ: undefined field: y:
14301453
- ./issue2209full.cue:35:9
14311454
-issue2209.full.Bar.resource.spec.minBar: undefined field: min:
@@ -1438,23 +1461,23 @@ diff old new
14381461
disambiguateClosed: (struct){
14391462
b: (#struct){ |((#struct){
14401463
x: (bool){ true }
1441-
@@ -121,7 +89,6 @@
1464+
@@ -134,7 +89,6 @@
14421465
// [incomplete] nestedNonMonotonic.incomplete.a.n2.p1.x.a.b: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
14431466
// ./in.cue:96:15
14441467
// ./in.cue:96:32
14451468
- // ./in.cue:97:12
14461469
c: (int){ 1 }
14471470
}
14481471
}
1449-
@@ -133,7 +100,6 @@
1472+
@@ -146,7 +100,6 @@
14501473
b: (_|_){
14511474
// [incomplete] nestedNonMonotonic.incomplete.a.n2.p2.x.a.b: invalid value {c:1} (does not satisfy struct.MinFields(2)): len(fields) < MinFields(2) (1 < 2):
14521475
// ./in.cue:102:15
14531476
- // ./in.cue:101:12
14541477
// ./in.cue:102:32
14551478
c: (int){ 1 }
14561479
}
1457-
@@ -159,16 +125,8 @@
1480+
@@ -172,16 +125,8 @@
14581481
x: ((null|struct)){ |((struct){
14591482
a: (struct){
14601483
b: (_|_){
@@ -1472,7 +1495,7 @@ diff old new
14721495
// ./in.cue:138:32
14731496
c: (int){ 1 }
14741497
d: (int){ 1 }
1475-
@@ -227,38 +185,60 @@
1498+
@@ -240,38 +185,60 @@
14761499
}, (#struct){
14771500
a: (string){ string }
14781501
d: (string){ string }
@@ -1565,7 +1588,7 @@ diff old new
15651588
d: (string){ string }
15661589
}) }
15671590
#B: (#struct){ |(*(#struct){
1568-
@@ -293,6 +273,17 @@
1591+
@@ -306,6 +273,17 @@
15691592
}, (#struct){
15701593
a: (string){ string }
15711594
d: (string){ string }
@@ -1583,7 +1606,7 @@ diff old new
15831606
}) }
15841607
#B: (#struct){ |(*(#struct){
15851608
}, (#struct){
1586-
@@ -327,10 +318,6 @@
1609+
@@ -340,10 +318,6 @@
15871610
#type: (#struct){
15881611
fieldName: ((string|struct)){ |((string){ string }, (#struct){
15891612
foo: (string){ string }
@@ -1594,7 +1617,7 @@ diff old new
15941617
}) }
15951618
}
15961619
#subtype: ((string|struct)){ |((string){ string }, (#struct){
1597-
@@ -364,9 +351,12 @@
1620+
@@ -377,9 +351,12 @@
15981621
}
15991622
}
16001623
t4: (struct){
@@ -1610,7 +1633,7 @@ diff old new
16101633
#D: (#struct){ |((#struct){
16111634
a: (null){ null }
16121635
}, (#struct){
1613-
@@ -410,12 +400,8 @@
1636+
@@ -423,12 +400,8 @@
16141637
#T: (list){
16151638
0: (string){ "d" }
16161639
}
@@ -1625,7 +1648,7 @@ diff old new
16251648
}
16261649
issue1940: (struct){
16271650
#T: (#list){
1628-
@@ -424,28 +410,18 @@
1651+
@@ -437,50 +410,24 @@
16291652
}
16301653
}
16311654
#A: (#struct){
@@ -1645,23 +1668,46 @@ diff old new
16451668
- 1: (list){
16461669
- }
16471670
- }
1648-
- }
1671+
+ type: ~(issue1940.#T)
1672+
}
1673+
}
1674+
}
1675+
#ID: (string){ |((string){ &(!~"^a", =~"^a") }, (string){ &(!~"^a", !~"[A-Z]") }, (string){ &(=~"^ab$", =~"^a") }, (string){ &(=~"^ab$", !~"[A-Z]") }, (string){ &(=~"^aB$", =~"^a") }, (string){ &(=~"^aB$", !~"[A-Z]") }) }
1676+
- ids: (_|_){
1677+
- // [eval]
1678+
+ ids: (#list){
1679+
0: (string){ "xyz" }
1680+
- 1: (_|_){
1681+
- // [eval] ids.1: invalid value "ab" (out of bound !~"^a"):
1682+
- // ./issue1417.cue:1:6
1683+
- // ./issue1417.cue:3:10
1684+
- // ./issue1417.cue:3:25
1685+
- }
1686+
- 2: (_|_){
1687+
- // [eval] ids.2: 2 errors in empty disjunction:
1688+
- // ids.2: invalid value "aB" (out of bound !~"^a"):
1689+
- // ./issue1417.cue:1:6
1690+
- // ./issue1417.cue:3:10
1691+
- // ./issue1417.cue:3:31
1692+
- // ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
1693+
- // ./issue1417.cue:2:15
1694+
- // ./issue1417.cue:3:10
1695+
- // ./issue1417.cue:3:31
16491696
- }
16501697
- }
16511698
- issue2209: (_|_){
16521699
- // [eval]
16531700
- simplified: (_|_){
16541701
- // [eval]
1655-
+ type: ~(issue1940.#T)
1656-
+ }
1657-
+ }
1702+
+ 1: (string){ "ab" }
1703+
+ 2: (string){ "aB" }
16581704
+ }
16591705
+ issue2209: (struct){
16601706
+ simplified: (struct){
16611707
t1: (struct){
16621708
#SpecFoo: (#struct){
16631709
foo: (#struct){
1664-
@@ -508,185 +484,118 @@
1710+
@@ -543,185 +490,118 @@
16651711
x: (int){ 1 }
16661712
}
16671713
}
@@ -1958,7 +2004,7 @@ diff old new
19582004
}
19592005
}
19602006
#Abstract: (#struct){
1961-
@@ -702,34 +611,34 @@
2007+
@@ -737,34 +617,34 @@
19622008
}
19632009
}) }
19642010
resource: (#struct){
@@ -2021,7 +2067,7 @@ diff old new
20212067
}
20222068
}
20232069
_#Spec: (#struct){ |(*(#struct){
2024-
@@ -756,36 +665,36 @@
2070+
@@ -791,36 +671,36 @@
20252071
}
20262072
}
20272073
_Thing: (#struct){
@@ -2087,7 +2133,7 @@ diff old new
20872133
}
20882134
#Constrained: (#struct){
20892135
spec: (#struct){ |(*(#struct){
2090-
@@ -869,19 +778,19 @@
2136+
@@ -904,19 +784,19 @@
20912137
common: (int){ 3 }
20922138
}
20932139
#FormFoo: (#struct){
@@ -2114,7 +2160,7 @@ diff old new
21142160
}) }
21152161
}
21162162
#Input: (#struct){
2117-
@@ -930,10 +839,23 @@
2163+
@@ -965,10 +845,23 @@
21182164
}
21192165
full: (struct){
21202166
metrics: (#list){
@@ -2144,14 +2190,14 @@ diff old new
21442190
value: (int){ 80 }
21452191
-- out/eval/stats --
21462192
Leaks: 4
2147-
Freed: 2339
2148-
Reused: 2323
2193+
Freed: 2368
2194+
Reused: 2352
21492195
Allocs: 20
21502196
Retain: 115
21512197

2152-
Unifications: 1260
2153-
Conjuncts: 3417
2154-
Disjuncts: 2454
2198+
Unifications: 1265
2199+
Conjuncts: 3458
2200+
Disjuncts: 2483
21552201
-- diff/todo/p1 --
21562202
issue2263.full: missing elimination, may be lack of closeContext
21572203
-- diff/todo/p2 --
@@ -2163,8 +2209,10 @@ issue2209.simplified.t2.BAZ: error reported in wrong location.
21632209
-- diff/explanation --
21642210
issue2209.simplified.t3: new evaluator fixes known bug.
21652211
preserveClosedness.medium.p*: discarding of default is correct.
2212+
issue1417: new evaluator fixes known bug
21662213
-- out/eval --
21672214
Errors:
2215+
ids.2: 2 errors in empty disjunction:
21682216
issue2209.full.Bar.resource.spec: 6 errors in empty disjunction:
21692217
issue2209.full.Bar.resource.spec.minBar: 2 errors in empty disjunction:
21702218
issue2209.full.Bar.resource.spec.minBar: conflicting values null and int (mismatched types null and int):
@@ -2189,6 +2237,18 @@ issue2209.full.Bar.resource.spec.minFoo: conflicting values null and int (mismat
21892237
./issue2209full.cue:83:16
21902238
./issue2209full.cue:92:13
21912239
./issue2209full.cue:105:20
2240+
ids.1: invalid value "ab" (out of bound !~"^a"):
2241+
./issue1417.cue:1:6
2242+
./issue1417.cue:3:10
2243+
./issue1417.cue:3:25
2244+
ids.2: invalid value "aB" (out of bound !~"^a"):
2245+
./issue1417.cue:1:6
2246+
./issue1417.cue:3:10
2247+
./issue1417.cue:3:31
2248+
ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
2249+
./issue1417.cue:2:15
2250+
./issue1417.cue:3:10
2251+
./issue1417.cue:3:31
21922252
issue2209.simplified.t3.BAZ: undefined field: y:
21932253
./issue2209full.cue:35:9
21942254
issue2209.full.Bar.resource.spec.minBar: undefined field: min:
@@ -2608,6 +2668,28 @@ Result:
26082668
}
26092669
}
26102670
}
2671+
#ID: (string){ |((string){ &(!~"^a", =~"^a") }, (string){ &(!~"^a", !~"[A-Z]") }, (string){ &(=~"^ab$", =~"^a") }, (string){ &(=~"^ab$", !~"[A-Z]") }, (string){ &(=~"^aB$", =~"^a") }, (string){ &(=~"^aB$", !~"[A-Z]") }) }
2672+
ids: (_|_){
2673+
// [eval]
2674+
0: (string){ "xyz" }
2675+
1: (_|_){
2676+
// [eval] ids.1: invalid value "ab" (out of bound !~"^a"):
2677+
// ./issue1417.cue:1:6
2678+
// ./issue1417.cue:3:10
2679+
// ./issue1417.cue:3:25
2680+
}
2681+
2: (_|_){
2682+
// [eval] ids.2: 2 errors in empty disjunction:
2683+
// ids.2: invalid value "aB" (out of bound !~"^a"):
2684+
// ./issue1417.cue:1:6
2685+
// ./issue1417.cue:3:10
2686+
// ./issue1417.cue:3:31
2687+
// ids.2: invalid value "aB" (out of bound !~"[A-Z]"):
2688+
// ./issue1417.cue:2:15
2689+
// ./issue1417.cue:3:10
2690+
// ./issue1417.cue:3:31
2691+
}
2692+
}
26112693
issue2209: (_|_){
26122694
// [eval]
26132695
simplified: (_|_){
@@ -3866,6 +3948,18 @@ Result:
38663948
})
38673949
}
38683950
}
3951+
--- issue1417.cue
3952+
{
3953+
#ID: (!~"^a"|=~"^ab$"|=~"^aB$")
3954+
#ID: (=~"^a"|!~"[A-Z]")
3955+
ids: ([
3956+
...〈1;#ID〉,
3957+
] & [
3958+
"xyz",
3959+
"ab",
3960+
"aB",
3961+
])
3962+
}
38693963
--- issue2209full.cue
38703964
{
38713965
issue2209: {

0 commit comments

Comments
 (0)