Skip to content

Commit

Permalink
internal/core/adt: remove unnecessary check
Browse files Browse the repository at this point in the history
The removed check used to be necessary to stop on cycles,
but the new structural cycle detection makes this no
longer necessary.

Note that CUE is allowed to report an error that occurs
on multiple locations on only one of them.

Fixes #2244

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ib8979ce3b45597fbcc4e3a4b4f88811773ffdd80
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549659
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
mpvl committed Mar 14, 2023
1 parent 06fbefe commit 1a0a81b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,21 @@ c2: (*{
}
-- out/eval/stats --
Leaks: 0
Freed: 48
Reused: 39
Freed: 52
Reused: 43
Allocs: 9
Retain: 12
Retain: 19

Unifications: 24
Conjuncts: 72
Disjuncts: 46
Conjuncts: 81
Disjuncts: 52
-- out/eval --
(struct){
a1: (_|_){
// [incomplete] a1: incomplete cause disjunction
}
a2: (_|_){
// [incomplete] a2: incomplete cause disjunction
// [cycle] cycle error:
// ./in.cue:2:5
}
a2: (int){ 1 }
a3: (int){ 1 }
b1: (int){ |((int){ 0 }, (int){ 1 }) }
b2: (int){ |((int){ 0 }, (int){ 1 }) }
Expand Down
19 changes: 9 additions & 10 deletions cue/testdata/cycle/issue241.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,22 @@ a: cell.a
b: cell.b
-- out/eval/stats --
Leaks: 0
Freed: 35
Reused: 29
Allocs: 6
Retain: 5
Freed: 47
Reused: 39
Allocs: 8
Retain: 7

Unifications: 11
Conjuncts: 70
Disjuncts: 33
Conjuncts: 103
Disjuncts: 47
-- out/eval --
(struct){
#Value: (int){ |((int){ 0 }, (int){ 1 }) }
foo: (_|_){
// [incomplete] foo: incomplete cause disjunction
}
bar: (_|_){
// [incomplete] bar: incomplete cause disjunction
// [incomplete] foo: unresolved disjunction 0 | 1 (type int):
// ./in.cue:4:6
}
bar: (int){ |((int){ 0 }, (int){ 1 }) }
Foo: (int){ 1 }
Bar: (int){ 0 }
cell: (struct){
Expand Down
16 changes: 7 additions & 9 deletions cue/testdata/cycle/issue429.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ er3: #nonEmptyRange & {
}
-- out/eval/stats --
Leaks: 0
Freed: 96
Reused: 89
Freed: 98
Reused: 91
Allocs: 7
Retain: 8
Retain: 12

Unifications: 40
Conjuncts: 150
Disjuncts: 96
Conjuncts: 154
Disjuncts: 101
-- out/eval --
Errors:
er3.min: 2 errors in empty disjunction:
Expand Down Expand Up @@ -134,11 +134,9 @@ Result:
}
#nonEmptyRange: (#struct){
min: (_|_){
// [incomplete] #nonEmptyRange.min: incomplete cause disjunction
}
max: (_|_){
// [incomplete] #nonEmptyRange.min: incomplete cause disjunction
// [cycle] cycle error
}
max: (number){ >1 }
}
r1: (#struct){
min: (int){ 3 }
Expand Down
13 changes: 0 additions & 13 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,6 @@ func (c *OpContext) Unify(v *Vertex, state VertexStatus) {

if !n.done() {
switch {
case len(n.disjunctions) > 0 && isCyclePlaceholder(v.BaseValue):
// We disallow entering computations of disjunctions with
// incomplete data.
if state == Finalized {
b := c.NewErrf("incomplete cause disjunction")
b.Code = IncompleteError
n.errs = CombineErrors(nil, n.errs, b)
v.SetValue(n.ctx, Finalized, b)
} else {
n.node.UpdateStatus(Partial)
}
return

case state < Conjuncts:
n.node.UpdateStatus(Partial)
return
Expand Down
24 changes: 12 additions & 12 deletions tools/flow/testdata/template.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,31 @@ graph TD
}
-- out/run/t1/stats --
Leaks: 0
Freed: 38
Reused: 31
Freed: 41
Reused: 34
Allocs: 7
Retain: 0

Unifications: 24
Conjuncts: 51
Disjuncts: 37
Conjuncts: 64
Disjuncts: 41
-- out/run/t2/stats --
Leaks: 0
Freed: 38
Reused: 38
Freed: 41
Reused: 41
Allocs: 0
Retain: 0

Unifications: 24
Conjuncts: 55
Disjuncts: 37
Conjuncts: 68
Disjuncts: 41
-- out/run/stats/totals --
Leaks: 0
Freed: 76
Reused: 69
Freed: 82
Reused: 75
Allocs: 7
Retain: 0

Unifications: 48
Conjuncts: 106
Disjuncts: 74
Conjuncts: 132
Disjuncts: 82

0 comments on commit 1a0a81b

Please sign in to comment.