Skip to content

Commit 9f913e0

Browse files
committed
internal/core/adt: fix EVAL counter issue
EVAL is used to signal that a closeContext is not closed until a node is done. However, this is not only meaningless if it crosses disjunction boundaries, but will also cause spurious allocations and counters that fail to decrement. This also fixes a bunch of tests in encoding/jsonschema Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I0839b1b8903252b0e0b6a01171c2ea2b43fff66f Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207442 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 0efb5e8 commit 9f913e0

File tree

8 files changed

+27
-30
lines changed

8 files changed

+27
-30
lines changed

encoding/jsonschema/external_teststats.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ v2:
66

77
v3:
88
schema extract (pass / total): 1054 / 1363 = 77.3%
9-
tests (pass / total): 3783 / 4803 = 78.8%
10-
tests on extracted schemas (pass / total): 3783 / 3955 = 95.7%
9+
tests (pass / total): 3788 / 4803 = 78.9%
10+
tests on extracted schemas (pass / total): 3788 / 3955 = 95.8%
1111

1212
Optional tests
1313

encoding/jsonschema/testdata/external/tests/draft2019-09/ref.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@
4444
"bar": false
4545
}
4646
},
47-
"valid": false,
48-
"skip": {
49-
"v3": "unexpected success"
50-
}
47+
"valid": false
5148
}
5249
]
5350
},

encoding/jsonschema/testdata/external/tests/draft2020-12/ref.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@
4444
"bar": false
4545
}
4646
},
47-
"valid": false,
48-
"skip": {
49-
"v3": "unexpected success"
50-
}
47+
"valid": false
5148
}
5249
]
5350
},

encoding/jsonschema/testdata/external/tests/draft4/ref.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343
"bar": false
4444
}
4545
},
46-
"valid": false,
47-
"skip": {
48-
"v3": "unexpected success"
49-
}
46+
"valid": false
5047
}
5148
]
5249
},

encoding/jsonschema/testdata/external/tests/draft6/ref.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343
"bar": false
4444
}
4545
},
46-
"valid": false,
47-
"skip": {
48-
"v3": "unexpected success"
49-
}
46+
"valid": false
5047
}
5148
]
5249
},

encoding/jsonschema/testdata/external/tests/draft7/ref.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343
"bar": false
4444
}
4545
},
46-
"valid": false,
47-
"skip": {
48-
"v3": "unexpected success"
49-
}
46+
"valid": false
5047
}
5148
]
5249
},

internal/core/adt/eval_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ var skipDebugDepErrors = map[string]int{
8686
"cycle/disjunction": 4,
8787
"cycle/evaluate": 1,
8888
"cycle/issue990": 1,
89-
"cycle/structural": 17,
89+
"cycle/structural": 13,
9090
"disjunctions/edge": 1,
9191
"disjunctions/errors": 3,
9292
"disjunctions/elimination": 19,

internal/core/adt/overlay.go

+19-7
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,19 @@ func (ctx *overlayContext) cloneRoot(root *nodeContext) *nodeContext {
8181
v := ctx.cloneVertex(root.node)
8282
v.IsDisjunct = true
8383

84+
// At this point we have copied all the mandatory closeContexts. There
85+
// may be derivative closeContexts copied as well.
86+
8487
// TODO: patch notifications to any node that is within the disjunct to
8588
// point to the new vertex instead.
8689

8790
// Initialize closeContexts: at this point, all closeContexts that need to
8891
// be cloned have been allocated and stored in closeContexts and can now be
8992
// initialized.
90-
for _, cc := range ctx.closeContexts {
93+
// Use an explicit index as initCloneCC uses allocCC, which MAY allocate a
94+
// new closeContext. It probably does not, but we use an index in case.
95+
for i := 0; i < len(ctx.closeContexts); i++ {
96+
cc := ctx.closeContexts[i]
9197
ctx.initCloneCC(cc)
9298
}
9399

@@ -309,12 +315,6 @@ func (ctx *overlayContext) allocCC(cc *closeContext) *closeContext {
309315
// src is set in the root closeContext when cloning a vertex.
310316
ctx.closeContexts = append(ctx.closeContexts, cc)
311317

312-
// needsCloseInSchedule is used as a boolean. The pointer to the original
313-
// closeContext is just used for reporting purposes.
314-
if cc.needsCloseInSchedule != nil {
315-
o.needsCloseInSchedule = ctx.allocCC(cc.needsCloseInSchedule)
316-
}
317-
318318
// We only explicitly tag dependencies of type ARC. Notifications that
319319
// point within the disjunct overlay will be tagged elsewhere.
320320
for _, a := range cc.arcs {
@@ -351,6 +351,18 @@ func (ctx *overlayContext) initCloneCC(x *closeContext) {
351351
o.Expr = x.Expr
352352
o.Patterns = append(o.Patterns, x.Patterns...)
353353

354+
// needsCloseInSchedule is a separate mechanism to signal nodes that have
355+
// completed. Do not signal such nodes if they are outside the current
356+
// copied graph.
357+
if cx := x.needsCloseInSchedule; cx != nil {
358+
if cx.src._cc.overlay == nil {
359+
o.needsCloseInSchedule = nil
360+
} else {
361+
// TODO: Debug assert: cx.overlay != nil
362+
o.needsCloseInSchedule = ctx.allocCC(cx)
363+
}
364+
}
365+
354366
// child and next always point to completed closeContexts. Moreover, only
355367
// fields that are immutable, such as Expr, are used. It is therefore not
356368
// necessary to use overlays.

0 commit comments

Comments
 (0)