Skip to content

Commit 4140094

Browse files
committed
internal/core/adt: bail on empty node
Some resolvers return 'emptyNode' as a value upon error, others nil. Treat both cases equally. Issue #2850 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I295cc58cd3836d95ecc4a459d6a56f5ac1393b66 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201894 Reviewed-by: Matthew Sackman <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent bf54346 commit 4140094

File tree

2 files changed

+28
-105
lines changed

2 files changed

+28
-105
lines changed

cue/testdata/cycle/structural.txtar

+26-104
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,6 @@ patternFail.issue2374.a.b: structural cycle
647647
shortPathFail.elipsis.t2.Foo.ref: structural cycle
648648
withLetFail._schema_1: structural cycle
649649
z1.z.g.h: structural cycle
650-
p3.a.a: field not allowed:
651-
./in.cue:248:5
652-
./in.cue:249:3
653-
p6.a.a: field not allowed:
654-
./in.cue:287:5
655-
./in.cue:288:3
656650
d3.config.0: structural cycle:
657651
./in.cue:317:13
658652
d3.x.0: structural cycle:
@@ -1082,7 +1076,7 @@ Result:
10821076
}
10831077
}
10841078
p3: (_|_){
1085-
// [eval]
1079+
// [structural cycle]
10861080
#S: (#struct){
10871081
#T: (#struct){
10881082
a: (#struct){
@@ -1105,15 +1099,7 @@ Result:
11051099
}
11061100
}
11071101
a: (_|_){
1108-
// [eval] p3.#U.#T.a.b.link: structural cycle
1109-
// p3.a.a: field not allowed:
1110-
// ./in.cue:248:5
1111-
// ./in.cue:249:3
1112-
a: (_|_){
1113-
// [eval] p3.a.a: field not allowed:
1114-
// ./in.cue:248:5
1115-
// ./in.cue:249:3
1116-
}
1102+
// [structural cycle] p3.#U.#T.a.b.link: structural cycle
11171103
}
11181104
}
11191105
p4: (struct){
@@ -1173,7 +1159,7 @@ Result:
11731159
}
11741160
}
11751161
p6: (_|_){
1176-
// [eval]
1162+
// [structural cycle]
11771163
#S: (#struct){
11781164
#T: (#struct){
11791165
a: (list){
@@ -1196,15 +1182,7 @@ Result:
11961182
}
11971183
}
11981184
a: (_|_){
1199-
// [eval] p6.#U.#T.a.0.link: structural cycle
1200-
// p6.a.a: field not allowed:
1201-
// ./in.cue:287:5
1202-
// ./in.cue:288:3
1203-
a: (_|_){
1204-
// [eval] p6.a.a: field not allowed:
1205-
// ./in.cue:287:5
1206-
// ./in.cue:288:3
1207-
}
1185+
// [structural cycle] p6.#U.#T.a.0.link: structural cycle
12081186
}
12091187
}
12101188
c1: (_|_){
@@ -1847,7 +1825,7 @@ diff old new
18471825
e1.a.c: structural cycle
18481826
e1.b.c: structural cycle
18491827
e2.a.c: structural cycle
1850-
@@ -32,61 +36,82 @@
1828+
@@ -32,61 +36,76 @@
18511829
./in.cue:403:5
18521830
./in.cue:404:5
18531831
e3.b.c: structural cycle
@@ -1930,12 +1908,6 @@ diff old new
19301908
- ./in.cue:301:26
19311909
-d3.x.indirect: structural cycle:
19321910
- ./in.cue:316:12
1933-
+p3.a.a: field not allowed:
1934-
+ ./in.cue:248:5
1935-
+ ./in.cue:249:3
1936-
+p6.a.a: field not allowed:
1937-
+ ./in.cue:287:5
1938-
+ ./in.cue:288:3
19391911
+d3.config.0: structural cycle:
19401912
+ ./in.cue:317:13
19411913
+d3.x.0: structural cycle:
@@ -1957,7 +1929,7 @@ diff old new
19571929

19581930
Result:
19591931
(_|_){
1960-
@@ -168,11 +193,17 @@
1932+
@@ -168,11 +187,17 @@
19611933
}
19621934
}
19631935
b4: (_|_){
@@ -1980,7 +1952,7 @@ diff old new
19801952
}
19811953
}
19821954
x: (_|_){
1983-
@@ -240,10 +271,9 @@
1955+
@@ -240,10 +265,9 @@
19841956
// [eval]
19851957
0: (_|_){
19861958
// [eval] b6.b.a.0: conflicting values 1 and [1] (mismatched types int and list):
@@ -1992,7 +1964,7 @@ diff old new
19921964
0: (_|_){
19931965
// [structural cycle] b6.b.a.0.0: structural cycle
19941966
}
1995-
@@ -261,11 +291,20 @@
1967+
@@ -261,11 +285,20 @@
19961968
}
19971969
}
19981970
b7: (_|_){
@@ -2018,7 +1990,7 @@ diff old new
20181990
}
20191991
}
20201992
a: (_|_){
2021-
@@ -304,7 +343,7 @@
1993+
@@ -304,7 +337,7 @@
20221994
#ref: (#struct){
20231995
ref: (string){ string }
20241996
}
@@ -2027,7 +1999,7 @@ diff old new
20271999
c: (#list){
20282000
0: ((string|struct)){ |((string){ string }, (#struct){
20292001
ref: (string){ string }
2030-
@@ -327,7 +366,9 @@
2002+
@@ -327,7 +360,9 @@
20312003
}) }
20322004
}
20332005
c: (#struct){
@@ -2038,7 +2010,7 @@ diff old new
20382010
}
20392011
d: (struct){
20402012
d: (struct){
2041-
@@ -372,7 +413,7 @@
2013+
@@ -372,7 +407,7 @@
20422014
// [structural cycle] b12b.#list.tail: structural cycle
20432015
}
20442016
list1: (_|_){
@@ -2047,7 +2019,7 @@ diff old new
20472019
}
20482020
}
20492021
b13: (_|_){
2050-
@@ -455,20 +496,34 @@
2022+
@@ -455,14 +490,28 @@
20512023
}
20522024
a: (_|_){
20532025
// [structural cycle]
@@ -2084,31 +2056,7 @@ diff old new
20842056
}
20852057
}
20862058
}
2087-
}
2088-
p3: (_|_){
2089-
- // [structural cycle]
2090-
+ // [eval]
2091-
#S: (#struct){
2092-
#T: (#struct){
2093-
a: (#struct){
2094-
@@ -491,7 +546,15 @@
2095-
}
2096-
}
2097-
a: (_|_){
2098-
- // [structural cycle] p3.#U.#T.a.b.link: structural cycle
2099-
+ // [eval] p3.#U.#T.a.b.link: structural cycle
2100-
+ // p3.a.a: field not allowed:
2101-
+ // ./in.cue:248:5
2102-
+ // ./in.cue:249:3
2103-
+ a: (_|_){
2104-
+ // [eval] p3.a.a: field not allowed:
2105-
+ // ./in.cue:248:5
2106-
+ // ./in.cue:249:3
2107-
+ }
2108-
}
2109-
}
2110-
p4: (struct){
2111-
@@ -532,11 +595,17 @@
2059+
@@ -532,11 +581,17 @@
21122060
}
21132061
a: (_|_){
21142062
// [structural cycle]
@@ -2131,33 +2079,7 @@ diff old new
21312079
}
21322080
}
21332081
}
2134-
@@ -545,7 +614,7 @@
2135-
}
2136-
}
2137-
p6: (_|_){
2138-
- // [structural cycle]
2139-
+ // [eval]
2140-
#S: (#struct){
2141-
#T: (#struct){
2142-
a: (list){
2143-
@@ -568,7 +637,15 @@
2144-
}
2145-
}
2146-
a: (_|_){
2147-
- // [structural cycle] p6.#U.#T.a.0.link: structural cycle
2148-
+ // [eval] p6.#U.#T.a.0.link: structural cycle
2149-
+ // p6.a.a: field not allowed:
2150-
+ // ./in.cue:287:5
2151-
+ // ./in.cue:288:3
2152-
+ a: (_|_){
2153-
+ // [eval] p6.a.a: field not allowed:
2154-
+ // ./in.cue:287:5
2155-
+ // ./in.cue:288:3
2156-
+ }
2157-
}
2158-
}
2159-
c1: (_|_){
2160-
@@ -578,12 +655,7 @@
2082+
@@ -578,12 +633,7 @@
21612083
b: (struct){
21622084
}
21632085
c: (_|_){
@@ -2171,7 +2093,7 @@ diff old new
21712093
}
21722094
}
21732095
}
2174-
@@ -599,56 +671,30 @@
2096+
@@ -599,56 +649,30 @@
21752097
// [structural cycle]
21762098
h: (int){ int }
21772099
t: (_|_){
@@ -2252,7 +2174,7 @@ diff old new
22522174
}
22532175
}
22542176
}
2255-
@@ -655,31 +701,41 @@
2177+
@@ -655,31 +679,41 @@
22562178
}
22572179
d3: (_|_){
22582180
// [structural cycle]
@@ -2314,7 +2236,7 @@ diff old new
23142236
}
23152237
}
23162238
shortPathFail: (_|_){
2317-
@@ -696,9 +752,7 @@
2239+
@@ -696,9 +730,7 @@
23182240
// [structural cycle]
23192241
t1: (struct){
23202242
#Foo: (#struct){
@@ -2325,7 +2247,7 @@ diff old new
23252247
}
23262248
}
23272249
t2: (_|_){
2328-
@@ -706,10 +760,7 @@
2250+
@@ -706,10 +738,7 @@
23292251
Foo: (_|_){
23302252
// [structural cycle]
23312253
ref: (_|_){
@@ -2337,7 +2259,7 @@ diff old new
23372259
}
23382260
}
23392261
}
2340-
@@ -740,20 +791,24 @@
2262+
@@ -740,20 +769,24 @@
23412263
schema: (_|_){
23422264
// [structural cycle]
23432265
next: (_|_){
@@ -2370,7 +2292,7 @@ diff old new
23702292
}
23712293
}
23722294
listOptOK: (struct){
2373-
@@ -809,11 +864,12 @@
2295+
@@ -809,11 +842,12 @@
23742296
// [eval] e3.a: conflicting values [a] and {c:a} (mismatched types list and struct):
23752297
// ./in.cue:400:5
23762298
// ./in.cue:401:5
@@ -2388,7 +2310,7 @@ diff old new
23882310
}
23892311
}
23902312
b: (_|_){
2391-
@@ -820,11 +876,12 @@
2313+
@@ -820,11 +854,12 @@
23922314
// [eval] e3.b: conflicting values [b] and {c:b} (mismatched types list and struct):
23932315
// ./in.cue:403:5
23942316
// ./in.cue:404:5
@@ -2406,7 +2328,7 @@ diff old new
24062328
}
24072329
}
24082330
}
2409-
@@ -833,41 +890,51 @@
2331+
@@ -833,41 +868,51 @@
24102332
a: (_|_){
24112333
// [eval]
24122334
0: (_|_){
@@ -2489,7 +2411,7 @@ diff old new
24892411
}
24902412
}
24912413
}
2492-
@@ -890,19 +957,14 @@
2414+
@@ -890,19 +935,14 @@
24932415
y: (_|_){
24942416
// [eval]
24952417
0: (_|_){
@@ -2512,7 +2434,7 @@ diff old new
25122434
}
25132435
1: (int){ 1 }
25142436
}
2515-
@@ -912,19 +974,14 @@
2437+
@@ -912,19 +952,14 @@
25162438
y: (_|_){
25172439
// [eval]
25182440
0: (_|_){
@@ -2535,7 +2457,7 @@ diff old new
25352457
}
25362458
1: (int){ 1 }
25372459
}
2538-
@@ -1028,9 +1085,7 @@
2460+
@@ -1028,9 +1063,7 @@
25392461
// [structural cycle]
25402462
f: (_|_){
25412463
// [structural cycle]
@@ -2546,7 +2468,7 @@ diff old new
25462468
}
25472469
g: (_|_){
25482470
// [structural cycle]
2549-
@@ -1177,19 +1232,19 @@
2471+
@@ -1177,19 +1210,19 @@
25502472
}
25512473
}
25522474
n4: (struct){

internal/core/adt/tasks.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func processResolver(ctx *OpContext, t *task, mode runMode) {
9797
// would be a pretty significant rework, though.
9898

9999
arc := r.resolve(ctx, oldOnly(0))
100-
if arc == nil {
100+
// TODO: ensure that resolve always returns one of these two.
101+
if arc == nil || arc == emptyNode {
101102
// TODO: yield instead?
102103
return
103104
}

0 commit comments

Comments
 (0)