Skip to content

Commit 7bb676e

Browse files
committed
internal/core/adt: remove Inline check
Now we simulate inline fields as being real fields, we can remove the inline check and treat them more permissively. Note that this also makes some inline calls more permissive, resulting in some nicer outcomes. Fixes #3634 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ia8b189a52e8d640d1d9b195c6a222cf6a31911ac Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1209388 Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 35ec59b commit 7bb676e

File tree

3 files changed

+48
-177
lines changed

3 files changed

+48
-177
lines changed

cue/testdata/cycle/builtins.txtar

Lines changed: 32 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,15 @@ issue3634: reduced: {
255255
out: len(#D & list.Repeat([#D & { a: b: 1 }], 1)[0])
256256
}
257257
-- out/evalalpha/stats --
258-
Leaks: 465
258+
Leaks: 484
259259
Freed: 0
260260
Reused: 0
261-
Allocs: 465
261+
Allocs: 484
262262
Retain: 0
263263

264-
Unifications: 397
265-
Conjuncts: 868
266-
Disjuncts: 34
264+
Unifications: 409
265+
Conjuncts: 920
266+
Disjuncts: 38
267267
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
268268
diff old new
269269
--- old
@@ -274,18 +274,18 @@ diff old new
274274
-Reused: 434
275275
-Allocs: 37
276276
-Retain: 99
277-
+Leaks: 465
277+
+Leaks: 484
278278
+Freed: 0
279279
+Reused: 0
280-
+Allocs: 465
280+
+Allocs: 484
281281
+Retain: 0
282282

283283
-Unifications: 441
284284
-Conjuncts: 821
285285
-Disjuncts: 537
286-
+Unifications: 397
287-
+Conjuncts: 868
288-
+Disjuncts: 34
286+
+Unifications: 409
287+
+Conjuncts: 920
288+
+Disjuncts: 38
289289
-- out/eval/stats --
290290
Leaks: 25
291291
Freed: 446
@@ -298,11 +298,6 @@ Conjuncts: 821
298298
Disjuncts: 537
299299
-- out/evalalpha --
300300
Errors:
301-
0.properties.foo: cannot combine regular field "required" with null:
302-
./issue3634.cue:6:26
303-
0.properties.foo: conflicting values null and {required:["bar","baz"]} (mismatched types null and struct):
304-
./issue3634.cue:6:26
305-
./issue3634.cue:11:20
306301
noCycle.t1.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1:
307302
./cycle.cue:4:7
308303
./cycle.cue:4:14
@@ -319,12 +314,6 @@ issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0
319314
./cycle.cue:31:13
320315
issue3649.cycle.t1.data.a.a: structural cycle:
321316
./cycle.cue:31:6
322-
0.properties.foo: structural cycle:
323-
./issue3634.cue:6:33
324-
0.properties.foo: 3 errors in empty disjunction::
325-
./issue3634.cue:9:26
326-
0.a: structural cycle:
327-
./issue3634.cue:17:7
328317
jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle:
329318
./jsoncycle.cue:4:8
330319
./jsoncycle.cue:5:8
@@ -543,40 +532,24 @@ Result:
543532
host: (string){ "mod.test" }
544533
}
545534
}
546-
issue3634: (_|_){
547-
// [structural cycle]
548-
full: (_|_){
549-
// [structural cycle]
535+
issue3634: (struct){
536+
full: (struct){
550537
#Schema: (#struct){
551538
required?: (list){
552539
}
553540
properties?: (#struct){
554541
}
555542
}
556-
out: (_|_){
557-
// [structural cycle] 0.properties.foo: cannot combine regular field "required" with null:
558-
// ./issue3634.cue:6:26
559-
// 0.properties.foo: conflicting values null and {required:["bar","baz"]} (mismatched types null and struct):
560-
// ./issue3634.cue:6:26
561-
// ./issue3634.cue:11:20
562-
// 0.properties.foo: structural cycle:
563-
// ./issue3634.cue:6:33
564-
// 0.properties.foo: 3 errors in empty disjunction::
565-
// ./issue3634.cue:9:26
566-
}
543+
out: (int){ 3 }
567544
}
568-
reduced: (_|_){
569-
// [structural cycle]
545+
reduced: (struct){
570546
#D: (#struct){
571547
b?: (int){ int }
572548
a?: (_|_){
573549
// [structural cycle] issue3634.reduced.#D.a: structural cycle
574550
}
575551
}
576-
out: (_|_){
577-
// [structural cycle] 0.a: structural cycle:
578-
// ./issue3634.cue:17:7
579-
}
552+
out: (int){ 1 }
580553
}
581554
}
582555
jsonCycle: (_|_){
@@ -884,14 +857,7 @@ Result:
884857
diff old new
885858
--- old
886859
+++ new
887-
@@ -1,26 +1,52 @@
888-
Errors:
889-
+0.properties.foo: cannot combine regular field "required" with null:
890-
+ ./issue3634.cue:6:26
891-
+0.properties.foo: conflicting values null and {required:["bar","baz"]} (mismatched types null and struct):
892-
+ ./issue3634.cue:6:26
893-
+ ./issue3634.cue:11:20
894-
noCycle.t1.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1:
860+
@@ -3,24 +3,39 @@
895861
./cycle.cue:4:7
896862
./cycle.cue:4:14
897863
./cycle.cue:5:13
@@ -919,12 +885,6 @@ diff old new
919885
+ ./cycle.cue:31:13
920886
+issue3649.cycle.t1.data.a.a: structural cycle:
921887
+ ./cycle.cue:31:6
922-
+0.properties.foo: structural cycle:
923-
+ ./issue3634.cue:6:33
924-
+0.properties.foo: 3 errors in empty disjunction::
925-
+ ./issue3634.cue:9:26
926-
+0.a: structural cycle:
927-
+ ./issue3634.cue:17:7
928888
+jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle:
929889
+ ./jsoncycle.cue:4:8
930890
+ ./jsoncycle.cue:5:8
@@ -949,7 +909,7 @@ diff old new
949909
issue3443.cycle2.fail.#S: invalid value {n:{n:{n:_}}} (does not satisfy matchN): 0 matched, expected 1:
950910
./matchn.cue:55:13
951911
./matchn.cue:55:20
952-
@@ -53,26 +79,21 @@
912+
@@ -53,26 +68,21 @@
953913
./yamlcycle.cue:15:8
954914
selfCycle.t1.c.d.d.d: structural cycle:
955915
./yamlcycle.cue:14:5
@@ -991,7 +951,7 @@ diff old new
991951

992952
Result:
993953
(_|_){
994-
@@ -88,10 +109,6 @@
954+
@@ -88,10 +98,6 @@
995955
// ./cycle.cue:4:7
996956
// ./cycle.cue:4:14
997957
// ./cycle.cue:5:13
@@ -1002,7 +962,7 @@ diff old new
1002962
}
1003963
}
1004964
#x: (_|_){
1005-
@@ -99,21 +116,20 @@
965+
@@ -99,21 +105,20 @@
1006966
// ./cycle.cue:4:7
1007967
// ./cycle.cue:4:14
1008968
// ./cycle.cue:5:13
@@ -1038,23 +998,23 @@ diff old new
1038998
}
1039999
#c: (#struct){
10401000
b?: (string){ string }
1041-
@@ -125,7 +141,6 @@
1001+
@@ -125,7 +130,6 @@
10421002
}
10431003
t2: (struct){
10441004
x: (struct){
10451005
- b?: (string){ string }
10461006
y: (struct){
10471007
a: (struct){
10481008
d: (struct){
1049-
@@ -133,6 +148,7 @@
1009+
@@ -133,6 +137,7 @@
10501010
}
10511011
}
10521012
}
10531013
+ b?: (string){ string }
10541014
}
10551015
c: (struct){
10561016
b?: (string){ string }
1057-
@@ -147,13 +163,22 @@
1017+
@@ -147,13 +152,22 @@
10581018
}
10591019
}
10601020
}
@@ -1084,56 +1044,7 @@ diff old new
10841044
}
10851045
#c: (#struct){
10861046
b: (string){ string }
1087-
@@ -219,8 +244,10 @@
1088-
host: (string){ "mod.test" }
1089-
}
1090-
}
1091-
- issue3634: (struct){
1092-
- full: (struct){
1093-
+ issue3634: (_|_){
1094-
+ // [structural cycle]
1095-
+ full: (_|_){
1096-
+ // [structural cycle]
1097-
#Schema: (#struct){
1098-
required?: (list){
1099-
}
1100-
@@ -227,9 +254,20 @@
1101-
properties?: (#struct){
1102-
}
1103-
}
1104-
- out: (int){ 3 }
1105-
- }
1106-
- reduced: (struct){
1107-
+ out: (_|_){
1108-
+ // [structural cycle] 0.properties.foo: cannot combine regular field "required" with null:
1109-
+ // ./issue3634.cue:6:26
1110-
+ // 0.properties.foo: conflicting values null and {required:["bar","baz"]} (mismatched types null and struct):
1111-
+ // ./issue3634.cue:6:26
1112-
+ // ./issue3634.cue:11:20
1113-
+ // 0.properties.foo: structural cycle:
1114-
+ // ./issue3634.cue:6:33
1115-
+ // 0.properties.foo: 3 errors in empty disjunction::
1116-
+ // ./issue3634.cue:9:26
1117-
+ }
1118-
+ }
1119-
+ reduced: (_|_){
1120-
+ // [structural cycle]
1121-
#D: (#struct){
1122-
b?: (int){ int }
1123-
a?: (_|_){
1124-
@@ -236,7 +274,10 @@
1125-
// [structural cycle] issue3634.reduced.#D.a: structural cycle
1126-
}
1127-
}
1128-
- out: (int){ 1 }
1129-
+ out: (_|_){
1130-
+ // [structural cycle] 0.a: structural cycle:
1131-
+ // ./issue3634.cue:17:7
1132-
+ }
1133-
}
1134-
}
1135-
jsonCycle: (_|_){
1136-
@@ -244,8 +285,12 @@
1047+
@@ -244,8 +258,12 @@
11371048
t1: (_|_){
11381049
// [structural cycle]
11391050
x: (_|_){
@@ -1148,7 +1059,7 @@ diff old new
11481059
}
11491060
}
11501061
}
1151-
@@ -254,8 +299,15 @@
1062+
@@ -254,8 +272,15 @@
11521063
structCycle: (_|_){
11531064
// [eval]
11541065
x: (_|_){
@@ -1166,7 +1077,7 @@ diff old new
11661077
}
11671078
}
11681079
ok: (struct){
1169-
@@ -318,7 +370,7 @@
1080+
@@ -318,7 +343,7 @@
11701081
}
11711082
}) }
11721083
noHang: (struct){
@@ -1175,7 +1086,7 @@ diff old new
11751086
n: (struct){
11761087
n: (_){ _ }
11771088
}
1178-
@@ -333,7 +385,8 @@
1089+
@@ -333,7 +358,8 @@
11791090
}
11801091
}) }
11811092
}
@@ -1185,7 +1096,7 @@ diff old new
11851096
#S: (_){ matchN(1, (#list){
11861097
0: (_|_){// {
11871098
// n: 〈2;#S〉
1188-
@@ -348,8 +401,21 @@
1099+
@@ -348,8 +374,21 @@
11891100
}
11901101
}) }
11911102
}
@@ -1209,7 +1120,7 @@ diff old new
12091120
n: (struct){
12101121
n: (_){ _ }
12111122
}
1212-
@@ -417,8 +483,8 @@
1123+
@@ -417,8 +456,8 @@
12131124
a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) }
12141125
}
12151126
data: (#struct){
@@ -1219,7 +1130,7 @@ diff old new
12191130
}
12201131
}
12211132
selfCycle: (_|_){
1222-
@@ -446,19 +512,8 @@
1133+
@@ -446,19 +485,8 @@
12231134
}
12241135
}
12251136
}
@@ -1241,7 +1152,7 @@ diff old new
12411152
}
12421153
}
12431154
yamlVal: (_|_){
1244-
@@ -466,25 +521,33 @@
1155+
@@ -466,25 +494,33 @@
12451156
t1: (_|_){
12461157
// [eval]
12471158
x: (_|_){
@@ -1289,7 +1200,7 @@ diff old new
12891200
}
12901201
}
12911202
t2: (_|_){
1292-
@@ -492,13 +555,16 @@
1203+
@@ -492,13 +528,16 @@
12931204
z: (_|_){
12941205
// [eval]
12951206
y: (_|_){
@@ -1313,7 +1224,7 @@ diff old new
13131224
}
13141225
}
13151226
}
1316-
@@ -505,8 +571,12 @@
1227+
@@ -505,8 +544,12 @@
13171228
yamlValidatePartial: (_|_){
13181229
// [structural cycle]
13191230
x: (_|_){

0 commit comments

Comments
 (0)