Skip to content

Commit

Permalink
internal/core/adt: fix FromDef
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mpvl committed Feb 24, 2025
1 parent 587d5a1 commit df327a6
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 415 deletions.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/testdata/script/vet_matchn.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exec cue vet -c schema.cue data.json
# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
env CUE_DEBUG=openinline=0
! exec cue vet -c schema.cue data.json #TODO Fix
exec cue vet -c schema.cue data.json

-- data.json --
{
Expand Down
32 changes: 16 additions & 16 deletions cue/testdata/cycle/builtins.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ listMatchN: ok: {
-- todo/p1 --
issue3443.noCycle: fix hang
-- out/evalalpha/stats --
Leaks: 426
Leaks: 427
Freed: 0
Reused: 0
Allocs: 426
Allocs: 427
Retain: 0

Unifications: 367
Conjuncts: 806
Unifications: 368
Conjuncts: 805
Disjuncts: 28
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
Expand All @@ -255,17 +255,17 @@ diff old new
-Reused: 402
-Allocs: 35
-Retain: 95
+Leaks: 426
+Leaks: 427
+Freed: 0
+Reused: 0
+Allocs: 426
+Allocs: 427
+Retain: 0

-Unifications: 409
-Conjuncts: 764
-Disjuncts: 501
+Unifications: 367
+Conjuncts: 806
+Unifications: 368
+Conjuncts: 805
+Disjuncts: 28
-- out/eval/stats --
Leaks: 23
Expand Down Expand Up @@ -293,8 +293,8 @@ issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0
./cycle.cue:31:6
./cycle.cue:28:11
./cycle.cue:31:13
issue3649.cycle.t1.data.a.a: field not allowed:
./cycle.cue:31:17
issue3649.cycle.t1.data.a.a: structural cycle:
./cycle.cue:31:6
jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle:
./jsoncycle.cue:4:8
./jsoncycle.cue:5:8
Expand Down Expand Up @@ -443,8 +443,8 @@ Result:
// ./cycle.cue:31:6
// ./cycle.cue:28:11
// ./cycle.cue:31:13
// issue3649.cycle.t1.data.a.a: field not allowed:
// ./cycle.cue:31:17
// issue3649.cycle.t1.data.a.a: structural cycle:
// ./cycle.cue:31:6
b: (string){ "foo" }
}
b: (string){ string }
Expand Down Expand Up @@ -844,8 +844,8 @@ diff old new
+ ./cycle.cue:31:6
+ ./cycle.cue:28:11
+ ./cycle.cue:31:13
+issue3649.cycle.t1.data.a.a: field not allowed:
+ ./cycle.cue:31:17
+issue3649.cycle.t1.data.a.a: structural cycle:
+ ./cycle.cue:31:6
+jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle:
+ ./jsoncycle.cue:4:8
+ ./jsoncycle.cue:5:8
Expand Down Expand Up @@ -997,8 +997,8 @@ diff old new
+ // ./cycle.cue:31:6
+ // ./cycle.cue:28:11
+ // ./cycle.cue:31:13
+ // issue3649.cycle.t1.data.a.a: field not allowed:
+ // ./cycle.cue:31:17
+ // issue3649.cycle.t1.data.a.a: structural cycle:
+ // ./cycle.cue:31:6
+ b: (string){ "foo" }
+ }
+ b: (string){ string }
Expand Down
Loading

0 comments on commit df327a6

Please sign in to comment.