Skip to content

Commit f752335

Browse files
committedJan 28, 2025·
internal/core/adt: force finalizing of shared values
When finalizing a value, CUE currently only finalized direct arcs and skipped shared values. The reasoning there is that CUE will anyway evaluated these shared values eventually as the stack unwinds, meaning that at the end of a CUE evaluation, all these shared values are evaluated anyway. However, this logic does not hold for builtins: if a value is passed to a builtin mid evaluation, a shared value may still be unprocessed. Basically, because evaluation has not finished yet, there is no guarantee that shared values are finalized. We now ensure that all shared values comply to the same requirements as those for the current node under evaluation. This fixes the tests added for 3648, but also removes some discrepancies between V2 and V3. In one case in particular, constraints.txtar:brokenRing, this CL reverses a fix and now makes V3 mimic the same bug as V2. We will accept this regression as not particularly harmful and the net result is certainly positive. Fixes #3648 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ie877e7d94107841e0d9cbcf8b6ecdbcfcde5676b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207912 Reviewed-by: Matthew Sackman <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 72c7c27 commit f752335

File tree

6 files changed

+156
-291
lines changed

6 files changed

+156
-291
lines changed
 

‎cue/testdata/cycle/comprehension.txtar

+14-65
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ issue2367: {
310310
}
311311

312312
-- out/evalalpha/stats --
313-
Leaks: 782
314-
Freed: 63
315-
Reused: 63
316-
Allocs: 782
313+
Leaks: 777
314+
Freed: 68
315+
Reused: 68
316+
Allocs: 777
317317
Retain: 0
318318

319319
Unifications: 502
@@ -583,17 +583,13 @@ Result:
583583
reject: (string){ string }
584584
}, (#struct){
585585
resource: (string){ string }
586-
}, (#struct){
587-
retry: ~(issue1881.p1.#AllOutputs.retry)
588586
}) }
589587
}
590588
}
591589
#Output: (#struct){ |((#struct){
592590
reject: (string){ string }
593591
}, (#struct){
594592
resource: (string){ string }
595-
}, (#struct){
596-
retry: ~(issue1881.p1.#AllOutputs.retry)
597593
}) }
598594
}
599595
p2: (struct){
@@ -790,60 +786,16 @@ diff old new
790786
}
791787
}
792788
acrossOr: (struct){
793-
@@ -254,27 +247,31 @@
789+
@@ -254,7 +247,7 @@
794790
issue1881: (struct){
795791
p1: (struct){
796792
o: (#struct){
797793
- retry: (#struct){
798-
- output: (#struct){
799-
- reject: (string){ "ok" }
800-
- }
801-
- }
802-
- }
803-
- #AllOutputs: (#struct){
804-
- reject: (string){ string }
805-
- resource: (string){ string }
806-
- retry: (#struct){
807-
- output: (#struct){ |((#struct){
808-
- reject: (string){ string }
809-
- }, (#struct){
810-
- resource: (string){ string }
811-
- }) }
812-
- }
813-
- }
814-
- #Output: (#struct){ |((#struct){
815-
- reject: (string){ string }
816-
- }, (#struct){
817-
- resource: (string){ string }
818794
+ retry: (struct){
819-
+ output: (#struct){
820-
+ reject: (string){ "ok" }
821-
+ }
822-
+ }
823-
+ }
824-
+ #AllOutputs: (#struct){
825-
+ reject: (string){ string }
826-
+ resource: (string){ string }
827-
+ retry: (#struct){
828-
+ output: (#struct){ |((#struct){
829-
+ reject: (string){ string }
830-
+ }, (#struct){
831-
+ resource: (string){ string }
832-
+ }, (#struct){
833-
+ retry: ~(issue1881.p1.#AllOutputs.retry)
834-
+ }) }
835-
+ }
836-
+ }
837-
+ #Output: (#struct){ |((#struct){
838-
+ reject: (string){ string }
839-
+ }, (#struct){
840-
+ resource: (string){ string }
841-
+ }, (#struct){
842-
+ retry: ~(issue1881.p1.#AllOutputs.retry)
843-
}) }
844-
}
845-
p2: (struct){
846-
@@ -290,7 +287,7 @@
795+
output: (#struct){
796+
reject: (string){ "ok" }
797+
}
798+
@@ -290,7 +283,7 @@
847799
}
848800
}
849801
o: (#struct){
@@ -852,7 +804,7 @@ diff old new
852804
output: (#struct){
853805
reject: (string){ "ok" }
854806
}
855-
@@ -320,7 +317,7 @@
807+
@@ -320,7 +313,7 @@
856808
resource: (string){ string }
857809
}) }
858810
o: (#struct){
@@ -871,10 +823,10 @@ diff old new
871823
-Reused: 1260
872824
-Allocs: 60
873825
-Retain: 145
874-
+Leaks: 782
875-
+Freed: 63
876-
+Reused: 63
877-
+Allocs: 782
826+
+Leaks: 777
827+
+Freed: 68
828+
+Reused: 68
829+
+Allocs: 777
878830
+Retain: 0
879831

880832
-Unifications: 832
@@ -895,9 +847,6 @@ Conjuncts: 2525
895847
Disjuncts: 1404
896848
-- diff/explanation --
897849
B.a.children: now correctly marked as incomplete
898-
-- diff/todo/p2 --
899-
issue1881.#AllOutputs.retry: additional entry.
900-
Might be error in practice and okay.
901850
-- out/eval --
902851
Errors:
903852
selfReferential.insertionError.A: field foo3 not allowed by earlier comprehension or reference cycle

‎cue/testdata/cycle/constraints.txtar

+76-80
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ Conjuncts: 399
588588
Disjuncts: 213
589589
-- out/evalalpha --
590590
Errors:
591+
brokenRing.t1.p1.T.b: structural cycle
591592
cyclicRing.t1.T.b: structural cycle
592593
mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b: structural cycle
593594
noCancelSelfInvoke.t1.x.c.b.b: structural cycle
@@ -848,22 +849,34 @@ Result:
848849
}
849850
issue1503: (_|_){
850851
// [structural cycle]
851-
a: (#struct){
852-
a: (#struct){
853-
one: (#struct){
854-
link: (#struct){
855-
a: (#struct){
856-
two: (#struct){
852+
a: (_|_){
853+
// [structural cycle]
854+
a: (_|_){
855+
// [structural cycle]
856+
one: (_|_){
857+
// [structural cycle]
858+
link: (_|_){
859+
// [structural cycle]
860+
a: (_|_){
861+
// [structural cycle]
862+
two: (_|_){
863+
// [structural cycle]
857864
link: ~(selfTriggerCycle.issue1503.#T)
858865
}
859-
b: (#struct){
860-
link: ~(selfTriggerCycle.issue1503.#T)
866+
b: (_|_){
867+
// [structural cycle]
868+
link: (_|_){
869+
// [structural cycle]
870+
}
861871
}
862872
}
863873
}
864874
}
865-
b: (#struct){
866-
link: ~(selfTriggerCycle.issue1503.#T)
875+
b: (_|_){
876+
// [structural cycle]
877+
link: (_|_){
878+
// [structural cycle]
879+
}
867880
}
868881
}
869882
}
@@ -935,14 +948,20 @@ Result:
935948
}
936949
}
937950
}
938-
brokenRing: (struct){
939-
t1: (struct){
940-
p1: (struct){
951+
brokenRing: (_|_){
952+
// [structural cycle]
953+
t1: (_|_){
954+
// [structural cycle]
955+
p1: (_|_){
956+
// [structural cycle]
941957
D: (struct){
942958
a?: ~(brokenRing.t1.p1.T)
943959
}
944-
T: (struct){
945-
b: ~(brokenRing.t1.p1.D)
960+
T: (_|_){
961+
// [structural cycle]
962+
b: (_|_){
963+
// [structural cycle] brokenRing.t1.p1.T.b: structural cycle
964+
}
946965
}
947966
}
948967
p2: (struct){
@@ -996,9 +1015,9 @@ Result:
9961015
diff old new
9971016
--- old
9981017
+++ new
999-
@@ -1,12 +1,10 @@
1018+
@@ -1,12 +1,11 @@
10001019
Errors:
1001-
-brokenRing.t1.p1.T.b: structural cycle
1020+
brokenRing.t1.p1.T.b: structural cycle
10021021
-cyclicRing.t1.D.a.b: structural cycle
10031022
cyclicRing.t1.T.b: structural cycle
10041023
-mutuallyTriggeringCycle.t1.x.c.b.b.b.b: structural cycle
@@ -1012,7 +1031,7 @@ diff old new
10121031
selfTriggerCycle.t1.#T.b.b: structural cycle
10131032
selfTriggerCycle.t2.b.c.a: structural cycle
10141033

1015-
@@ -152,18 +150,10 @@
1034+
@@ -152,18 +151,10 @@
10161035
#D: (#struct){
10171036
}
10181037
#E: (#struct){
@@ -1035,7 +1054,7 @@ diff old new
10351054
}
10361055
#S: (#struct){
10371056
y: (#struct){
1038-
@@ -201,18 +191,15 @@
1057+
@@ -201,18 +192,15 @@
10391058
// [structural cycle]
10401059
c: (_|_){
10411060
// [structural cycle]
@@ -1060,7 +1079,7 @@ diff old new
10601079
}
10611080
}
10621081
}
1063-
@@ -221,12 +208,7 @@
1082+
@@ -221,12 +209,7 @@
10641083
// [structural cycle]
10651084
t1: (_|_){
10661085
// [structural cycle]
@@ -1074,7 +1093,7 @@ diff old new
10741093
#T: (_|_){
10751094
// [structural cycle]
10761095
b: (_|_){
1077-
@@ -266,13 +248,7 @@
1096+
@@ -266,13 +249,7 @@
10781097
c: (_|_){
10791098
// [structural cycle]
10801099
b: (_|_){
@@ -1089,49 +1108,47 @@ diff old new
10891108
}
10901109
}
10911110
}
1092-
@@ -283,25 +259,22 @@
1093-
}
1094-
issue1503: (_|_){
1095-
// [structural cycle]
1096-
- a: (_|_){
1097-
- // [structural cycle]
1098-
- a: (_|_){
1099-
- // [structural cycle]
1111+
@@ -287,20 +264,29 @@
1112+
// [structural cycle]
1113+
a: (_|_){
1114+
// [structural cycle]
11001115
- b: (_|_){
11011116
- // [structural cycle]
11021117
- link: (_|_){
11031118
- // [structural cycle]
11041119
- }
11051120
- }
1106-
- one: (_|_){
1107-
- // [structural cycle]
1108-
- link: (_|_){
1109-
- // [structural cycle]
1121+
one: (_|_){
1122+
// [structural cycle]
1123+
link: (_|_){
1124+
// [structural cycle]
11101125
- a: (struct){
11111126
- two: (struct){
11121127
- }
11131128
- }
1114-
- }
1115-
+ a: (#struct){
1116-
+ a: (#struct){
1117-
+ one: (#struct){
1118-
+ link: (#struct){
1119-
+ a: (#struct){
1120-
+ two: (#struct){
1129+
+ a: (_|_){
1130+
+ // [structural cycle]
1131+
+ two: (_|_){
1132+
+ // [structural cycle]
11211133
+ link: ~(selfTriggerCycle.issue1503.#T)
11221134
+ }
1123-
+ b: (#struct){
1124-
+ link: ~(selfTriggerCycle.issue1503.#T)
1135+
+ b: (_|_){
1136+
+ // [structural cycle]
1137+
+ link: (_|_){
1138+
+ // [structural cycle]
1139+
+ }
11251140
+ }
11261141
+ }
11271142
+ }
11281143
+ }
1129-
+ b: (#struct){
1130-
+ link: ~(selfTriggerCycle.issue1503.#T)
1144+
+ b: (_|_){
1145+
+ // [structural cycle]
1146+
+ link: (_|_){
1147+
+ // [structural cycle]
1148+
}
11311149
}
11321150
}
1133-
}
1134-
@@ -336,7 +309,10 @@
1151+
@@ -336,7 +322,10 @@
11351152
b: (_|_){
11361153
// [structural cycle]
11371154
b: (_|_){
@@ -1143,55 +1160,34 @@ diff old new
11431160
}
11441161
}
11451162
}
1146-
@@ -370,34 +346,19 @@
1147-
}
1148-
}
1149-
}
1150-
- brokenRing: (_|_){
1151-
- // [structural cycle]
1152-
- t1: (_|_){
1153-
- // [structural cycle]
1154-
- p1: (_|_){
1155-
- // [structural cycle]
1156-
- D: (struct){
1163+
@@ -377,12 +366,7 @@
1164+
p1: (_|_){
1165+
// [structural cycle]
1166+
D: (struct){
11571167
- a?: (_|_){
11581168
- // [structural cycle]
11591169
- b: (_|_){
11601170
- // [structural cycle] brokenRing.t1.p1.D.a.b: structural cycle
11611171
- }
11621172
- }
1163-
- }
1164-
- T: (_|_){
1165-
- // [structural cycle]
1166-
- b: (_|_){
1167-
- // [structural cycle] brokenRing.t1.p1.T.b: structural cycle
1168-
- }
1169-
- }
1170-
- }
1171-
- p2: (struct){
1172-
- T: (struct){
1173+
+ a?: ~(brokenRing.t1.p1.T)
1174+
}
1175+
T: (_|_){
1176+
// [structural cycle]
1177+
@@ -393,11 +377,7 @@
1178+
}
1179+
p2: (struct){
1180+
T: (struct){
11731181
- b: (struct){
11741182
- a?: (_|_){
11751183
- // [structural cycle] brokenRing.t1.p2.T.b.a: structural cycle
11761184
- }
11771185
- }
1178-
+ brokenRing: (struct){
1179-
+ t1: (struct){
1180-
+ p1: (struct){
1181-
+ D: (struct){
1182-
+ a?: ~(brokenRing.t1.p1.T)
1183-
+ }
1184-
+ T: (struct){
1185-
+ b: ~(brokenRing.t1.p1.D)
1186-
+ }
1187-
+ }
1188-
+ p2: (struct){
1189-
+ T: (struct){
11901186
+ b: ~(brokenRing.t1.p2.D)
11911187
}
11921188
D: (struct){
11931189
a?: (_|_){
1194-
@@ -431,12 +392,7 @@
1190+
@@ -431,12 +411,7 @@
11951191
// [structural cycle]
11961192
D: (_|_){
11971193
// [structural cycle]

‎cue/testdata/cycle/structural.txtar

+52-59
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ e4.b.0.0.0: conflicting values [{c:1}] and {} (mismatched types list and struct)
685685
./in.cue:423:6
686686
./in.cue:424:10
687687
e4.b.0.0.0: structural cycle
688+
issue2545.#B.A: structural cycle
688689
nestedList.v1e.y.0: 4 errors in empty disjunction:
689690
nestedList.v1e.y.0: conflicting values [[2],1] and int (mismatched types list and int):
690691
./in.cue:438:11
@@ -1404,12 +1405,16 @@ Result:
14041405
}
14051406
}
14061407
}
1407-
issue2545: (struct){
1408+
issue2545: (_|_){
1409+
// [structural cycle]
14081410
#A: (#struct){
14091411
B?: ~(issue2545.#B)
14101412
}
1411-
#B: (#struct){
1412-
A: ~(issue2545.#A)
1413+
#B: (_|_){
1414+
// [structural cycle]
1415+
A: (_|_){
1416+
// [structural cycle] issue2545.#B.A: structural cycle
1417+
}
14131418
}
14141419
}
14151420
e1: (_|_){
@@ -1869,7 +1874,7 @@ diff old new
18691874
e1.a.c: structural cycle
18701875
e1.b.c: structural cycle
18711876
e2.a.c: structural cycle
1872-
@@ -32,62 +37,94 @@
1877+
@@ -32,62 +37,95 @@
18731878
./in.cue:415:5
18741879
./in.cue:416:5
18751880
e3.b.c: structural cycle
@@ -1916,7 +1921,6 @@ diff old new
19161921
./in.cue:423:6
19171922
- ./in.cue:424:6
19181923
- ./in.cue:424:10
1919-
-issue2545.#B.A: structural cycle
19201924
+ ./in.cue:424:10
19211925
+e4.b.0.0.0: 4 errors in empty disjunction:
19221926
+e4.b.0.0.0: conflicting values [{c:1}] and {c:1} (mismatched types list and struct):
@@ -1926,6 +1930,7 @@ diff old new
19261930
+ ./in.cue:423:6
19271931
+ ./in.cue:424:10
19281932
+e4.b.0.0.0: structural cycle
1933+
issue2545.#B.A: structural cycle
19291934
nestedList.v1e.y.0: 4 errors in empty disjunction:
19301935
-nestedList.v1e.y.0: conflicting values int and [[2],1] (mismatched types int and list):
19311936
+nestedList.v1e.y.0: conflicting values [[2],1] and int (mismatched types list and int):
@@ -1991,7 +1996,7 @@ diff old new
19911996

19921997
Result:
19931998
(_|_){
1994-
@@ -129,10 +166,7 @@
1999+
@@ -129,10 +167,7 @@
19952000
a7: (struct){
19962001
a: (string){ "foo" }
19972002
b: (struct){
@@ -2003,7 +2008,7 @@ diff old new
20032008
y: (string){ "foo" }
20042009
}
20052010
c: (struct){
2006-
@@ -169,11 +203,17 @@
2011+
@@ -169,11 +204,17 @@
20072012
}
20082013
}
20092014
b4: (_|_){
@@ -2026,7 +2031,7 @@ diff old new
20262031
}
20272032
}
20282033
x: (_|_){
2029-
@@ -241,10 +281,9 @@
2034+
@@ -241,10 +282,9 @@
20302035
// [eval]
20312036
0: (_|_){
20322037
// [eval] b6.b.a.0: conflicting values 1 and [1] (mismatched types int and list):
@@ -2038,7 +2043,7 @@ diff old new
20382043
0: (_|_){
20392044
// [structural cycle] b6.b.a.0.0: structural cycle
20402045
}
2041-
@@ -262,11 +301,20 @@
2046+
@@ -262,11 +302,20 @@
20422047
}
20432048
}
20442049
b7: (_|_){
@@ -2064,7 +2069,7 @@ diff old new
20642069
}
20652070
}
20662071
a: (_|_){
2067-
@@ -277,9 +325,7 @@
2072+
@@ -277,9 +326,7 @@
20682073
}
20692074
}
20702075
b8: (struct){
@@ -2075,7 +2080,7 @@ diff old new
20752080
a: (struct){
20762081
f: (string){ string }
20772082
}
2078-
@@ -305,7 +351,7 @@
2083+
@@ -305,7 +352,7 @@
20792084
#ref: (#struct){
20802085
ref: (string){ string }
20812086
}
@@ -2084,7 +2089,7 @@ diff old new
20842089
c: (#list){
20852090
0: ((string|struct)){ |((string){ string }, (#struct){
20862091
ref: (string){ string }
2087-
@@ -328,7 +374,13 @@
2092+
@@ -328,7 +375,13 @@
20882093
}) }
20892094
}
20902095
c: (#struct){
@@ -2099,7 +2104,7 @@ diff old new
20992104
}
21002105
d: (struct){
21012106
d: (struct){
2102-
@@ -338,9 +390,7 @@
2107+
@@ -338,9 +391,7 @@
21032108
}
21042109
b11: (struct){
21052110
#list: (#struct){
@@ -2110,7 +2115,7 @@ diff old new
21102115
}
21112116
}
21122117
b12: (struct){
2113-
@@ -357,7 +407,11 @@
2118+
@@ -357,7 +408,11 @@
21142119
value: (int){ 3 }
21152120
tail: (#struct){
21162121
value: (int){ 4 }
@@ -2123,7 +2128,7 @@ diff old new
21232128
sum: (int){ 4 }
21242129
}
21252130
sum: (int){ 7 }
2126-
@@ -429,10 +483,7 @@
2131+
@@ -429,10 +484,7 @@
21272132
link: (#struct){
21282133
a: (#struct){
21292134
two: (#struct){
@@ -2135,7 +2140,7 @@ diff old new
21352140
}
21362141
}
21372142
}
2138-
@@ -506,10 +557,7 @@
2143+
@@ -506,10 +558,7 @@
21392144
link: (#struct){
21402145
a: (#list){
21412146
0: (#struct){
@@ -2147,7 +2152,7 @@ diff old new
21472152
}
21482153
}
21492154
}
2150-
@@ -600,47 +648,27 @@
2155+
@@ -600,47 +649,27 @@
21512156
// [structural cycle]
21522157
h: (int){ int }
21532158
t: (_|_){
@@ -2212,7 +2217,7 @@ diff old new
22122217
c: (_|_){
22132218
// [structural cycle]
22142219
d: (_|_){
2215-
@@ -667,28 +695,25 @@
2220+
@@ -667,28 +696,25 @@
22162221
}
22172222
x: (_|_){
22182223
// [structural cycle]
@@ -2246,7 +2251,7 @@ diff old new
22462251
#List: (#struct){
22472252
Next: (null){ null }
22482253
}
2249-
@@ -697,9 +722,7 @@
2254+
@@ -697,9 +723,7 @@
22502255
// [structural cycle]
22512256
t1: (struct){
22522257
#Foo: (#struct){
@@ -2257,7 +2262,7 @@ diff old new
22572262
}
22582263
}
22592264
t2: (_|_){
2260-
@@ -707,10 +730,7 @@
2265+
@@ -707,10 +731,7 @@
22612266
Foo: (_|_){
22622267
// [structural cycle]
22632268
ref: (_|_){
@@ -2269,7 +2274,7 @@ diff old new
22692274
}
22702275
}
22712276
}
2272-
@@ -717,9 +737,7 @@
2277+
@@ -717,9 +738,7 @@
22732278
}
22742279
comprehension: (struct){
22752280
#list: (#struct){
@@ -2280,7 +2285,7 @@ diff old new
22802285
}
22812286
}
22822287
}
2283-
@@ -745,8 +763,7 @@
2288+
@@ -745,8 +764,7 @@
22842289
}
22852290
}
22862291
let _schema_1#1 = (_|_){
@@ -2290,7 +2295,7 @@ diff old new
22902295
}
22912296
}
22922297
fieldsSumInfinite: (_|_){
2293-
@@ -757,7 +774,8 @@
2298+
@@ -757,7 +775,8 @@
22942299
fries: (float){ 2.00 }
22952300
sprite: (float){ 1.00 }
22962301
total: (_|_){
@@ -2300,44 +2305,32 @@ diff old new
23002305
}
23012306
}
23022307
}
2303-
@@ -772,27 +790,16 @@
2308+
@@ -772,9 +791,7 @@
23042309
head: (int){ 3 }
23052310
tail: (struct){
23062311
head: (int){ 2 }
23072312
- tail?: (_|_){
23082313
- // [structural cycle] listOptOK.a.tail.tail: structural cycle
23092314
- }
2310-
- }
2311-
- }
2312-
- }
2313-
- issue2545: (_|_){
2314-
- // [structural cycle]
23152315
+ tail?: ~(listOptOK.list)
2316-
+ }
2317-
+ }
2318-
+ }
2319-
+ issue2545: (struct){
2316+
}
2317+
}
2318+
}
2319+
@@ -781,12 +798,7 @@
2320+
issue2545: (_|_){
2321+
// [structural cycle]
23202322
#A: (#struct){
23212323
- B?: (_|_){
23222324
- // [structural cycle]
23232325
- A: (_|_){
23242326
- // [structural cycle] issue2545.#A.B.A: structural cycle
23252327
- }
23262328
- }
2327-
- }
2328-
- #B: (_|_){
2329-
- // [structural cycle]
2330-
- A: (_|_){
2331-
- // [structural cycle] issue2545.#B.A: structural cycle
2332-
- }
23332329
+ B?: ~(issue2545.#B)
2334-
+ }
2335-
+ #B: (#struct){
2336-
+ A: ~(issue2545.#A)
23372330
}
2338-
}
2339-
e1: (_|_){
2340-
@@ -831,11 +838,12 @@
2331+
#B: (_|_){
2332+
// [structural cycle]
2333+
@@ -831,11 +843,12 @@
23412334
// [eval] e3.a: conflicting values [a] and {c:a} (mismatched types list and struct):
23422335
// ./in.cue:412:5
23432336
// ./in.cue:413:5
@@ -2355,7 +2348,7 @@ diff old new
23552348
}
23562349
}
23572350
b: (_|_){
2358-
@@ -842,11 +850,12 @@
2351+
@@ -842,11 +855,12 @@
23592352
// [eval] e3.b: conflicting values [b] and {c:b} (mismatched types list and struct):
23602353
// ./in.cue:415:5
23612354
// ./in.cue:416:5
@@ -2373,7 +2366,7 @@ diff old new
23732366
}
23742367
}
23752368
}
2376-
@@ -855,38 +864,72 @@
2369+
@@ -855,38 +869,72 @@
23772370
a: (_|_){
23782371
// [eval]
23792372
0: (_|_){
@@ -2468,7 +2461,7 @@ diff old new
24682461
0: (struct){
24692462
c: (int){ 1 }
24702463
}
2471-
@@ -913,17 +956,16 @@
2464+
@@ -913,17 +961,16 @@
24722465
// [eval]
24732466
0: (_|_){
24742467
// [eval] nestedList.v1e.y.0: 4 errors in empty disjunction:
@@ -2491,7 +2484,7 @@ diff old new
24912484
1: (int){ 1 }
24922485
}
24932486
1: (int){ 1 }
2494-
@@ -935,17 +977,16 @@
2487+
@@ -935,17 +982,16 @@
24952488
// [eval]
24962489
0: (_|_){
24972490
// [eval] nestedList.v2e.y.0: 4 errors in empty disjunction:
@@ -2514,7 +2507,7 @@ diff old new
25142507
1: (int){ 1 }
25152508
}
25162509
1: (int){ 1 }
2517-
@@ -999,7 +1040,10 @@
2510+
@@ -999,7 +1045,10 @@
25182511
head: (int){ 3 }
25192512
tail: (struct){
25202513
head: (int){ 4 }
@@ -2526,7 +2519,7 @@ diff old new
25262519
}
25272520
}
25282521
}
2529-
@@ -1013,7 +1057,10 @@
2522+
@@ -1013,7 +1062,10 @@
25302523
head: (int){ 2 }
25312524
tail: (struct){
25322525
head: (int){ 3 }
@@ -2538,7 +2531,7 @@ diff old new
25382531
}
25392532
}
25402533
}
2541-
@@ -1027,8 +1074,12 @@
2534+
@@ -1027,8 +1079,12 @@
25422535
head: (int){ 2 }
25432536
tail: (struct){ |((struct){
25442537
head: (int){ 3 }
@@ -2553,7 +2546,7 @@ diff old new
25532546
}, (struct){
25542547
head: (int){ 3 }
25552548
}) }
2556-
@@ -1050,9 +1101,7 @@
2549+
@@ -1050,9 +1106,7 @@
25572550
// [structural cycle]
25582551
f: (_|_){
25592552
// [structural cycle]
@@ -2564,7 +2557,7 @@ diff old new
25642557
}
25652558
g: (_|_){
25662559
// [structural cycle]
2567-
@@ -1073,10 +1122,7 @@
2560+
@@ -1073,10 +1127,7 @@
25682561
x: (_){ _ }
25692562
y: (_){ _ }
25702563
}
@@ -2576,7 +2569,7 @@ diff old new
25762569
}
25772570
}
25782571
t2: (struct){
2579-
@@ -1089,10 +1135,7 @@
2572+
@@ -1089,10 +1140,7 @@
25802573
x: (_){ _ }
25812574
y: (_){ _ }
25822575
}
@@ -2588,7 +2581,7 @@ diff old new
25882581
}
25892582
}
25902583
t3: (struct){
2591-
@@ -1107,16 +1150,8 @@
2584+
@@ -1107,16 +1155,8 @@
25922585
y: (_){ _ }
25932586
z: (_){ _ }
25942587
}
@@ -2607,7 +2600,7 @@ diff old new
26072600
}
26082601
}
26092602
t4: (struct){
2610-
@@ -1132,51 +1167,11 @@
2603+
@@ -1132,51 +1172,11 @@
26112604
y: (_){ _ }
26122605
z: (_){ _ }
26132606
}
@@ -2664,7 +2657,7 @@ diff old new
26642657
}
26652658
}
26662659
t5: (struct){
2667-
@@ -1187,18 +1182,8 @@
2660+
@@ -1187,18 +1187,8 @@
26682661
}
26692662
}
26702663
C: (struct){
@@ -2685,7 +2678,7 @@ diff old new
26852678
}
26862679
}
26872680
}
2688-
@@ -1221,19 +1206,19 @@
2681+
@@ -1221,19 +1211,19 @@
26892682
}
26902683
}
26912684
n4: (struct){

‎cue/testdata/eval/disjunctions.txtar

-13
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,6 @@ Result:
623623
}, (#struct){
624624
_ok: (bool){ true }
625625
let Ok#2 = (bool){ true }
626-
}, (#struct){
627-
_ok: (bool){ true }
628-
let Ok#2 = (bool){ true }
629626
}, (#struct){
630627
_ok: (bool){ true }
631628
let Ok#2multi = 〈0;_ok〉
@@ -733,16 +730,6 @@ diff old new
733730
}
734731
}
735732
}
736-
@@ -371,6 +353,9 @@
737-
let Ok#2 = (bool){ true }
738-
}, (#struct){
739-
_ok: (bool){ true }
740-
+ let Ok#2 = (bool){ true }
741-
+ }, (#struct){
742-
+ _ok: (bool){ true }
743-
let Ok#2multi = 〈0;_ok〉
744-
x: (bool){ true }
745-
}) }
746733
-- diff/todo/p1 --
747734
issue3597.t1.foo: duplicate disjunct
748735
-- diff/todo/p3 --

‎cue/testdata/resolve/048_builtins.txtar

+10-74
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ stringListErrors.c.result: cannot use int (type int) as string in argument 2 to
134134
decimalListErrors.a.result: invalid list element 0 in argument 0 to call: cannot use value string (string) as number:
135135
./in.cue:43:11
136136
./in.cue:42:7
137-
issue3648.reduced.foo.a: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
138-
./issue3648.cue:7:6
139-
issue3648.full.foo.allRedirects: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
140-
./issue3648.cue:17:17
141137

142138
Result:
143139
(_|_){
@@ -248,32 +244,25 @@ Result:
248244
}
249245
}
250246
}
251-
issue3648: (_|_){
252-
// [eval]
253-
reduced: (_|_){
254-
// [eval]
255-
foo: (_|_){
256-
// [eval]
257-
a: (_|_){
258-
// [eval] issue3648.reduced.foo.a: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
259-
// ./issue3648.cue:7:6
247+
issue3648: (struct){
248+
reduced: (struct){
249+
foo: (struct){
250+
a: (#list){
251+
0: (struct){
252+
}
260253
}
261254
b: (#list){
262255
0: (struct){
263256
}
264257
}
265258
}
266259
}
267-
full: (_|_){
268-
// [eval]
260+
full: (struct){
269261
#Redirect: (#struct){
270262
path?: (string){ string }
271263
}
272-
foo: (_|_){
273-
// [eval]
274-
allRedirects: (_|_){
275-
// [eval] issue3648.full.foo.allRedirects: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
276-
// ./issue3648.cue:17:17
264+
foo: (struct){
265+
allRedirects: (#list){
277266
}
278267
redirects: (list){
279268
}
@@ -299,18 +288,7 @@ diff old new
299288
./in.cue:20:14
300289
./in.cue:20:24
301290
a3.a: invalid value "bar" (out of bound =~"oo"):
302-
@@ -26,6 +22,10 @@
303-
decimalListErrors.a.result: invalid list element 0 in argument 0 to call: cannot use value string (string) as number:
304-
./in.cue:43:11
305-
./in.cue:42:7
306-
+issue3648.reduced.foo.a: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
307-
+ ./issue3648.cue:7:6
308-
+issue3648.full.foo.allRedirects: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
309-
+ ./issue3648.cue:17:17
310-
311-
Result:
312-
(_|_){
313-
@@ -70,13 +70,9 @@
291+
@@ -70,13 +66,9 @@
314292
a: (_|_){
315293
// [eval] o3.a: 2 errors in empty disjunction:
316294
// o3.a: conflicting values "bar" and "foo":
@@ -324,48 +302,6 @@ diff old new
324302
// ./in.cue:20:14
325303
// ./in.cue:20:24
326304
}
327-
@@ -140,12 +136,15 @@
328-
}
329-
}
330-
}
331-
- issue3648: (struct){
332-
- reduced: (struct){
333-
- foo: (struct){
334-
- a: (#list){
335-
- 0: (struct){
336-
- }
337-
+ issue3648: (_|_){
338-
+ // [eval]
339-
+ reduced: (_|_){
340-
+ // [eval]
341-
+ foo: (_|_){
342-
+ // [eval]
343-
+ a: (_|_){
344-
+ // [eval] issue3648.reduced.foo.a: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
345-
+ // ./issue3648.cue:7:6
346-
}
347-
b: (#list){
348-
0: (struct){
349-
@@ -153,12 +152,16 @@
350-
}
351-
}
352-
}
353-
- full: (struct){
354-
+ full: (_|_){
355-
+ // [eval]
356-
#Redirect: (#struct){
357-
path?: (string){ string }
358-
}
359-
- foo: (struct){
360-
- allRedirects: (#list){
361-
+ foo: (_|_){
362-
+ // [eval]
363-
+ allRedirects: (_|_){
364-
+ // [eval] issue3648.full.foo.allRedirects: error in call to list.Concat: not properly initialized (state: unprocessed, value: *adt.Vertex):
365-
+ // ./issue3648.cue:17:17
366-
}
367-
redirects: (list){
368-
}
369305
-- diff/todo/p2 --
370306
Missing error positions.
371307
-- out/eval --

‎internal/core/adt/unify.go

+4
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool {
355355
}
356356
v.status = w.status
357357

358+
// Ensure that shared nodes comply to the same requirements as we
359+
// need for the current node.
360+
w.unify(c, needs, mode)
361+
358362
return true
359363
}
360364

0 commit comments

Comments
 (0)
Please sign in to comment.