Skip to content

Commit df327a6

Browse files
committed
internal/core/adt: fix FromDef
This CL does some magic with FromDef in order to make the tests pass again after the reduction in closeContext graph depth. In general, FromDef should be taken from the ConjunctGroup leafs. However, sometimes FromDef is passed down too aggressively. We therefore erase the incoming FromDef in adt.Unify. At the same time, when adt.Unify is called from the API and passes a Vertex, we still need to honor the ClosedRecursive flag. We therefore keep setting this flag for adt.Unify (in addConjuncts). Another issue is that in insertSkipConjuncts, we now need to clear the FromDef not only in ConjunctGroups, but any conjunct with a lower depth, because there is no longer a conjunct group corresponding to each increase in depth of the graph. Issue #2850 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I89d53ff14e374350c1fff317d2f1baf20268aaec Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1209184 Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 587d5a1 commit df327a6

File tree

6 files changed

+78
-415
lines changed

6 files changed

+78
-415
lines changed

cmd/cue/cmd/testdata/script/vet_matchn.txtar

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exec cue vet -c schema.cue data.json
55
# With the new evaluator.
66
env CUE_EXPERIMENT=evalv3=1
77
env CUE_DEBUG=openinline=0
8-
! exec cue vet -c schema.cue data.json #TODO Fix
8+
exec cue vet -c schema.cue data.json
99

1010
-- data.json --
1111
{

cue/testdata/cycle/builtins.txtar

+16-16
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ listMatchN: ok: {
236236
-- todo/p1 --
237237
issue3443.noCycle: fix hang
238238
-- out/evalalpha/stats --
239-
Leaks: 426
239+
Leaks: 427
240240
Freed: 0
241241
Reused: 0
242-
Allocs: 426
242+
Allocs: 427
243243
Retain: 0
244244

245-
Unifications: 367
246-
Conjuncts: 806
245+
Unifications: 368
246+
Conjuncts: 805
247247
Disjuncts: 28
248248
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
249249
diff old new
@@ -255,17 +255,17 @@ diff old new
255255
-Reused: 402
256256
-Allocs: 35
257257
-Retain: 95
258-
+Leaks: 426
258+
+Leaks: 427
259259
+Freed: 0
260260
+Reused: 0
261-
+Allocs: 426
261+
+Allocs: 427
262262
+Retain: 0
263263

264264
-Unifications: 409
265265
-Conjuncts: 764
266266
-Disjuncts: 501
267-
+Unifications: 367
268-
+Conjuncts: 806
267+
+Unifications: 368
268+
+Conjuncts: 805
269269
+Disjuncts: 28
270270
-- out/eval/stats --
271271
Leaks: 23
@@ -293,8 +293,8 @@ issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0
293293
./cycle.cue:31:6
294294
./cycle.cue:28:11
295295
./cycle.cue:31:13
296-
issue3649.cycle.t1.data.a.a: field not allowed:
297-
./cycle.cue:31:17
296+
issue3649.cycle.t1.data.a.a: structural cycle:
297+
./cycle.cue:31:6
298298
jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle:
299299
./jsoncycle.cue:4:8
300300
./jsoncycle.cue:5:8
@@ -443,8 +443,8 @@ Result:
443443
// ./cycle.cue:31:6
444444
// ./cycle.cue:28:11
445445
// ./cycle.cue:31:13
446-
// issue3649.cycle.t1.data.a.a: field not allowed:
447-
// ./cycle.cue:31:17
446+
// issue3649.cycle.t1.data.a.a: structural cycle:
447+
// ./cycle.cue:31:6
448448
b: (string){ "foo" }
449449
}
450450
b: (string){ string }
@@ -844,8 +844,8 @@ diff old new
844844
+ ./cycle.cue:31:6
845845
+ ./cycle.cue:28:11
846846
+ ./cycle.cue:31:13
847-
+issue3649.cycle.t1.data.a.a: field not allowed:
848-
+ ./cycle.cue:31:17
847+
+issue3649.cycle.t1.data.a.a: structural cycle:
848+
+ ./cycle.cue:31:6
849849
+jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle:
850850
+ ./jsoncycle.cue:4:8
851851
+ ./jsoncycle.cue:5:8
@@ -997,8 +997,8 @@ diff old new
997997
+ // ./cycle.cue:31:6
998998
+ // ./cycle.cue:28:11
999999
+ // ./cycle.cue:31:13
1000-
+ // issue3649.cycle.t1.data.a.a: field not allowed:
1001-
+ // ./cycle.cue:31:17
1000+
+ // issue3649.cycle.t1.data.a.a: structural cycle:
1001+
+ // ./cycle.cue:31:6
10021002
+ b: (string){ "foo" }
10031003
+ }
10041004
+ b: (string){ string }

0 commit comments

Comments
 (0)