Skip to content

Commit a3db8b8

Browse files
committed
internal/core/adt: mark conjunct for incomplete disjunct
A node can be checked for closedness if all arcs are known. Even though this should probably be the case. In case, not, though, currently conjuncts were not always added if a task was not fully evaluated. This was originally done as the conjunct info was not cumulative, so we did not know which information was relevant in all cases, such as disjunctions. Now it _is_ cumulative, we can simply mark the disjunction straight away, so that it can provide evidence even if a disjunction was not yet completed. We also mark cHasTop for basic types that are top. This is an alternative representation and it is probably not necessary, but it serves as a defensive measure. Fixes #3934 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I739ee42bb1d8ff3b83c86f50ee90045eba2017a6 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1215545 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent d9bfe59 commit a3db8b8

File tree

4 files changed

+55
-69
lines changed

4 files changed

+55
-69
lines changed

cue/testdata/cycle/comprehension.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Unifications: 510
360360
Conjuncts: 1511
361361
Disjuncts: 190
362362

363-
CloseIDElems: 10222
363+
CloseIDElems: 10053
364364
NumCloseIDs: 811
365365
-- out/evalalpha --
366366
Errors:
@@ -1296,7 +1296,7 @@ diff old new
12961296
+Conjuncts: 1511
12971297
+Disjuncts: 190
12981298
+
1299-
+CloseIDElems: 10222
1299+
+CloseIDElems: 10053
13001300
+NumCloseIDs: 811
13011301
-- out/eval/stats --
13021302
Leaks: 74

cue/testdata/definitions/typocheck.txtar

Lines changed: 45 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,6 @@ embed.withIndirect.err: field not allowed:
525525
./in.cue:87:8
526526
issue3920.out.a.b: field not allowed:
527527
./chaineddef.cue:5:6
528-
issue3934.out.foo: field not allowed:
529-
./issue3934.cue:3:3
530-
./issue3934.cue:9:8
531528
embed.openValidator.t2.a.b: invalid value 1 (does not satisfy matchN): 0 matched, expected 1:
532529
./validators.cue:21:5
533530
./validators.cue:21:12
@@ -1315,14 +1312,9 @@ Result:
13151312
out: ~(reduced.t2._in)
13161313
}
13171314
}
1318-
issue3934: (_|_){
1319-
// [eval]
1320-
out: (_|_){
1321-
// [eval]
1322-
foo: (_|_){
1323-
// [eval] issue3934.out.foo: field not allowed:
1324-
// ./issue3934.cue:3:3
1325-
// ./issue3934.cue:9:8
1315+
issue3934: (struct){
1316+
out: (#struct){
1317+
foo: (#struct){
13261318
}
13271319
}
13281320
#Foo: (#struct){
@@ -1502,7 +1494,7 @@ Result:
15021494
diff old new
15031495
--- old
15041496
+++ new
1505-
@@ -1,81 +1,34 @@
1497+
@@ -1,81 +1,31 @@
15061498
Errors:
15071499
and.transitive.err.out.err: field not allowed:
15081500
- ./in.cue:42:5
@@ -1583,13 +1575,10 @@ diff old new
15831575
- ./validators.cue:18:5
15841576
+issue3920.out.a.b: field not allowed:
15851577
+ ./chaineddef.cue:5:6
1586-
+issue3934.out.foo: field not allowed:
1587-
+ ./issue3934.cue:3:3
1588-
+ ./issue3934.cue:9:8
15891578
embed.openValidator.t2.a.b: invalid value 1 (does not satisfy matchN): 0 matched, expected 1:
15901579
./validators.cue:21:5
15911580
./validators.cue:21:12
1592-
@@ -85,17 +38,21 @@
1581+
@@ -85,17 +35,21 @@
15931582
Result:
15941583
(_|_){
15951584
// [eval]
@@ -1622,7 +1611,7 @@ diff old new
16221611
}
16231612
#B: (#struct){
16241613
c?: (string){ string }
1625-
@@ -181,14 +138,11 @@
1614+
@@ -181,14 +135,11 @@
16261615
}
16271616
a: (_|_){
16281617
// [eval]
@@ -1638,7 +1627,7 @@ diff old new
16381627
}
16391628
}
16401629
andInStruct: (_|_){
1641-
@@ -198,14 +152,11 @@
1630+
@@ -198,14 +149,11 @@
16421631
}
16431632
a: (_|_){
16441633
// [eval]
@@ -1654,7 +1643,7 @@ diff old new
16541643
}
16551644
}
16561645
embedDefWithEmbedding: (_|_){
1657-
@@ -215,15 +166,11 @@
1646+
@@ -215,15 +163,11 @@
16581647
}
16591648
a: (_|_){
16601649
// [eval]
@@ -1671,7 +1660,7 @@ diff old new
16711660
}
16721661
}
16731662
embedComprehension: (_|_){
1674-
@@ -233,16 +180,11 @@
1663+
@@ -233,16 +177,11 @@
16751664
}
16761665
a: (_|_){
16771666
// [eval]
@@ -1689,7 +1678,7 @@ diff old new
16891678
}
16901679
}
16911680
fieldWithAnd: (_|_){
1692-
@@ -253,9 +195,6 @@
1681+
@@ -253,9 +192,6 @@
16931682
// [eval]
16941683
err: (_|_){
16951684
// [eval] embed.fieldWithAnd.a.err: field not allowed:
@@ -1699,7 +1688,7 @@ diff old new
16991688
// ./in.cue:20:13
17001689
}
17011690
}
1702-
@@ -266,20 +205,15 @@
1691+
@@ -266,20 +202,15 @@
17031692
a: (int){ int }
17041693
}
17051694
B: (struct){
@@ -1725,7 +1714,7 @@ diff old new
17251714
}
17261715
}
17271716
andEmbed: (_|_){
1728-
@@ -295,17 +229,11 @@
1717+
@@ -295,17 +226,11 @@
17291718
}
17301719
d: (_|_){
17311720
// [eval]
@@ -1744,7 +1733,7 @@ diff old new
17441733
}
17451734
}
17461735
nonDef: (struct){
1747-
@@ -314,12 +242,12 @@
1736+
@@ -314,12 +239,12 @@
17481737
a: (string){ string }
17491738
}
17501739
#Y: (#struct){
@@ -1761,7 +1750,7 @@ diff old new
17611750
}
17621751
}
17631752
}
1764-
@@ -329,12 +257,12 @@
1753+
@@ -329,12 +254,12 @@
17651754
Name: (string){ string }
17661755
}
17671756
#Step: (#struct){
@@ -1778,7 +1767,7 @@ diff old new
17781767
}
17791768
out: (#struct){
17801769
Name: (string){ "foo" }
1781-
@@ -344,21 +272,15 @@
1770+
@@ -344,21 +269,15 @@
17821771
}
17831772
withIndirect: (_|_){
17841773
// [eval]
@@ -1805,7 +1794,7 @@ diff old new
18051794
}
18061795
normalValidator: (_|_){
18071796
// [eval]
1808-
@@ -368,20 +290,17 @@
1797+
@@ -368,20 +287,17 @@
18091798
}
18101799
x: (_|_){
18111800
// [eval]
@@ -1829,7 +1818,7 @@ diff old new
18291818
#X: (_){
18301819
matchN(0, (#list){
18311820
})
1832-
@@ -388,17 +307,10 @@
1821+
@@ -388,17 +304,10 @@
18331822
a?: (int){ int }
18341823
b?: (int){ int }
18351824
}
@@ -1851,7 +1840,7 @@ diff old new
18511840
}
18521841
}
18531842
t2: (_|_){
1854-
@@ -417,10 +329,7 @@
1843+
@@ -417,10 +326,7 @@
18551844
// [eval]
18561845
b: (_|_){
18571846
// [eval] embed.openValidator.t2.a.b: conflicting values 1 and {b?:Y} (mismatched types int and struct):
@@ -1862,7 +1851,7 @@ diff old new
18621851
// ./validators.cue:24:8
18631852
// embed.openValidator.t2.a.b: invalid value 1 (does not satisfy matchN): 0 matched, expected 1:
18641853
// ./validators.cue:21:5
1865-
@@ -463,16 +372,11 @@
1854+
@@ -463,16 +369,11 @@
18661855
}
18671856
out: (_|_){
18681857
// [eval]
@@ -1880,7 +1869,7 @@ diff old new
18801869
}
18811870
}
18821871
}
1883-
@@ -505,17 +409,11 @@
1872+
@@ -505,17 +406,11 @@
18841873
}
18851874
out: (_|_){
18861875
// [eval]
@@ -1899,7 +1888,7 @@ diff old new
18991888
}
19001889
}
19011890
}
1902-
@@ -561,8 +459,8 @@
1891+
@@ -561,8 +456,8 @@
19031892
// ./issue3832.cue:8:16
19041893
}
19051894
outFirstName: (_|_){
@@ -1910,7 +1899,7 @@ diff old new
19101899
}
19111900
}
19121901
}
1913-
@@ -572,35 +470,27 @@
1902+
@@ -572,35 +467,27 @@
19141903
}, (#struct){
19151904
pass: (#struct){
19161905
let self#1 = (_|_){
@@ -1956,7 +1945,7 @@ diff old new
19561945
pass: (#struct){
19571946
let self#1 = (#struct){
19581947
firstName: (string){ "Sam" }
1959-
@@ -607,18 +497,21 @@
1948+
@@ -607,18 +494,21 @@
19601949
}
19611950
outFirstName: (string){ "Sam" }
19621951
}
@@ -1990,7 +1979,7 @@ diff old new
19901979
}
19911980
issue3833: (struct){
19921981
out: (#struct){
1993-
@@ -694,12 +587,8 @@
1982+
@@ -694,12 +584,8 @@
19941983
globalField: (string){ string }
19951984
}
19961985
#Context: (#struct){
@@ -2005,7 +1994,7 @@ diff old new
20051994
}
20061995
out: (struct){
20071996
ingress: (#struct){
2008-
@@ -727,22 +616,22 @@
1997+
@@ -727,22 +613,22 @@
20091998
#Z: (#struct){
20101999
}
20112000
x: (#struct){
@@ -2044,7 +2033,7 @@ diff old new
20442033
z: (int){ 1 }
20452034
}
20462035
}
2047-
@@ -752,22 +641,22 @@
2036+
@@ -752,22 +638,22 @@
20482037
#Z: (#struct){
20492038
}
20502039
x: (#struct){
@@ -2083,7 +2072,7 @@ diff old new
20832072
z: (int){ 1 }
20842073
}
20852074
}
2086-
@@ -782,11 +671,7 @@
2075+
@@ -782,11 +668,7 @@
20872076
}
20882077
}
20892078
#JobConfig: (#struct){
@@ -2096,7 +2085,7 @@ diff old new
20962085
job: (#struct){
20972086
image: (string){ "foo:v1" }
20982087
vcs: (string){ "git" }
2099-
@@ -850,7 +735,7 @@
2088+
@@ -850,7 +732,7 @@
21002089
}
21012090
}
21022091
out: (#struct){
@@ -2105,7 +2094,7 @@ diff old new
21052094
input: (#struct){
21062095
image: (string){ "someimage" }
21072096
env: (string){ "FOO" }
2108-
@@ -882,11 +767,11 @@
2097+
@@ -882,11 +764,11 @@
21092098
_in: (_){ _ }
21102099
out: (_){ _ }
21112100
}
@@ -2122,7 +2111,7 @@ diff old new
21222111
e: (string){ "foo" }
21232112
f: (int){ 1 }
21242113
}
2125-
@@ -919,35 +804,27 @@
2114+
@@ -919,35 +801,22 @@
21262115
_in: (_){ _ }
21272116
out: (_){ _ }
21282117
}
@@ -2144,17 +2133,6 @@ diff old new
21442133
- f: (int){ 1 }
21452134
- }
21462135
- }
2147-
- }
2148-
- }
2149-
- issue3934: (struct){
2150-
- out: (#struct){
2151-
- foo: ((null|struct)){ |(*(#struct){
2152-
- bar: (int){ 3 }
2153-
- }, (#struct){
2154-
- extra?: ((null|struct)){ |((null){ null }, (#struct){
2155-
- }) }
2156-
- bar?: (int){ int }
2157-
- }, (null){ null }) }
21582136
+ _in: (#struct){
21592137
+ a: (#struct){
21602138
+ e: (string){ "foo" }
@@ -2165,21 +2143,23 @@ diff old new
21652143
+ }
21662144
+ }
21672145
+ out: ~(reduced.t2._in)
2168-
+ }
2169-
+ }
2170-
+ issue3934: (_|_){
2171-
+ // [eval]
2172-
+ out: (_|_){
2173-
+ // [eval]
2174-
+ foo: (_|_){
2175-
+ // [eval] issue3934.out.foo: field not allowed:
2176-
+ // ./issue3934.cue:3:3
2177-
+ // ./issue3934.cue:9:8
2146+
}
2147+
}
2148+
issue3934: (struct){
2149+
out: (#struct){
2150+
- foo: ((null|struct)){ |(*(#struct){
2151+
- bar: (int){ 3 }
2152+
- }, (#struct){
2153+
- extra?: ((null|struct)){ |((null){ null }, (#struct){
2154+
- }) }
2155+
- bar?: (int){ int }
2156+
- }, (null){ null }) }
2157+
+ foo: (#struct){
21782158
+ }
21792159
}
21802160
#Foo: (#struct){
21812161
foo?: ((null|struct)){ |(*(#struct){
2182-
@@ -1012,38 +889,11 @@
2162+
@@ -1012,38 +881,11 @@
21832163
#Main: (#struct){
21842164
namespace: (string){ string }
21852165
output: (_|_){
@@ -2220,7 +2200,7 @@ diff old new
22202200
let base#6 = (#struct){
22212201
someMsg: (string){ string }
22222202
obs: (#struct){ |(*(#struct){
2223-
@@ -1086,6 +936,19 @@
2203+
@@ -1086,6 +928,19 @@
22242204
}
22252205
}
22262206
}
@@ -2240,7 +2220,7 @@ diff old new
22402220
}
22412221
}
22422222
out: (#struct){
2243-
@@ -1115,17 +978,8 @@
2223+
@@ -1115,17 +970,8 @@
22442224
// ./validators.cue:32:17
22452225
// disjunction.withErr.t1.out.b1.b2.b3: undefined field: mayExistLater:
22462226
// ./validators.cue:29:22

cue/testdata/eval/issue3672.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ Unifications: 623
310310
Conjuncts: 2667
311311
Disjuncts: 637
312312

313-
CloseIDElems: 9461
313+
CloseIDElems: 9460
314314
NumCloseIDs: 717
315315
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
316316
diff old new
@@ -336,7 +336,7 @@ diff old new
336336
+Conjuncts: 2667
337337
+Disjuncts: 637
338338
+
339-
+CloseIDElems: 9461
339+
+CloseIDElems: 9460
340340
+NumCloseIDs: 717
341341
-- out/eval/stats --
342342
Leaks: 245

0 commit comments

Comments
 (0)